homepage Welcome to WebmasterWorld Guest from 54.163.91.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
IE vs Netscape
Maven




msg:1494238
 6:53 am on Jan 25, 2004 (gmt 0)

This script works great in IE but has no effect in Netscape, anyone know why?
-----**--
<!-- Hide script from older browsers

var clockID = 0;

function UpdateAstoniaTimer(){
if(clockID) {
clearTimeout(clockID);
clockID = 0;
}

var rTDate = new Date();
var def = (rTDate.getTimezoneOffset()/60)%2;

var rTHour = rTDate.getHours() + def + 1;
var rTMin = rTDate.getMinutes();
var rTSec = rTDate.getSeconds();

var aTimeInMinutes = (rTSec/5) + (rTMin*12) + (rTHour % 2) * 720;
var astoniaHours = Math.floor(aTimeInMinutes/60);
var astoniaMinutes = Math.floor(aTimeInMinutes % 60);

if(astoniaMinutes < 10){
astoniaMinutes = "0" + astoniaMinutes;
}
if(astoniaHours < 10){
astoniaHours = "0" + astoniaHours;
}

AstonClock.innerHTML= "" + astoniaHours +":" + astoniaMinutes + " Aston Standard Time ";

clockID = setTimeout("UpdateAstoniaTimer()", 1000);

AstonClock.document= "" + astoniaHours +":" + astoniaMinutes + " Aston Standard Time ";

clockID = setTimeout("UpdateAstoniaTimer()", 1000);
}


function StartAstoniaTimer(){
clockID = setTimeout("UpdateAstoniaTimer()", 500);
}

function KillAstoniaTimer(){
if(clockID) {
clearTimeout(clockID);
clockID = 0;
}
}

// end hiding contents
-->
-----**--
The html page is:

<html><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<BODY onload="StartAstoniaTimer()" onunload="KillAstoniaTimer()" text=#ffffff bgColor=#000000 leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
<CENTER>
<!--<SCRIPT SRC="frameenforcer.js">
</SCRIPT>-->
<form name="aTime"></form>
<span id="AstonClock" style="background: #000000; position: absolute; middle: 10; top: 1; color: #C0C7FF; font-weight: bold; font-family: Latha ;"></span>

<SCRIPT LANGUAGE="JavaScript" SRC="ast.js">
</SCRIPT>
<body onload="StartAstoniaTimer()" onunload="KillAstoniaTimer()">

</center>
</body></body>
<html>

Any imput would be appreciated, thank you.

 

DrDoc




msg:1494239
 7:30 am on Jan 25, 2004 (gmt 0)

Welcome to Webmaster World!
First, I would recommend you running your HTML code through a validator [validator.w3.org]. Also, which Netscape are you talking about? The most recent, or ancient NN4.x?

Maven




msg:1494240
 11:08 am on Jan 25, 2004 (gmt 0)

Netscape 7.1 and thanx for the welcome, gonna try the validator now, see if it works :)

Maven




msg:1494241
 4:56 am on Jan 28, 2004 (gmt 0)

Umm still having a bit of trouble, the checker didn't really help any. Anyone got any ideas? Thanx for the assistance if you do.

wickydoodah




msg:1494242
 5:24 am on Jan 28, 2004 (gmt 0)

You need to try validating your html code again. As you have it now, you have some very significant errors in it.

Missing <html> closing tag
Missing <head> section - meta tag belongs in there
Duplicate <body> sections - only one allowed!

And these are just to get you started...

IE is VERY forgiving of bad html coding, but Netscape will choke on it everytime. That may be why it won't work in Netscape even though IE can work it's way through it.

Get your html in compliance, then check your page in Netscape again... it may work.

DrDoc




msg:1494243
 5:40 am on Jan 28, 2004 (gmt 0)

The validator helps TONS, but only if you are using a doctype. Here's a list of valid doctypes: [w3.org...]

I recommend using HTML 4.01 transitional or strict (strict is preferable)

DrDoc




msg:1494244
 5:49 am on Jan 28, 2004 (gmt 0)

Below are the results of attempting to parse this document with an SGML parser.

Line 5, column 70: an attribute value must be a literal unless it contains only name characters (explain...).  
..." onunload="KillAstoniaTimer()" text=#ffffff bgColor=#000000 leftMargin=0 top
----------------------------------------^

Line 5, column 86: an attribute value must be a literal unless it contains only name characters (explain...).  
...AstoniaTimer()" text=#ffffff bgColor=#000000 leftMargin=0 topMargin=0 marginw
----------------------------------------^

Line 5, column 105: there is no attribute "LEFTMARGIN" (explain...).  
...t=#ffffff bgColor=#000000 leftMargin=0 topMargin=0 marginwidth="0" marginheig
----------------------------------------^

Line 5, column 117: there is no attribute "TOPMARGIN" (explain...).  
...Color=#000000 leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
----------------------------------------^

Line 5, column 131: there is no attribute "MARGINWIDTH" (explain...).  
...leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
----------------------------------------^

Line 5, column 148: there is no attribute "MARGINHEIGHT" (explain...).  
...argin=0 marginwidth="0" marginheight="0">
----------------------------------------^

Line 5, column 151: document type does not allow element "BODY" here (explain...).  
...in=0 marginwidth="0" marginheight="0">
----------------------------------------^

Line 9, column 18: required attribute "ACTION" not specified (explain...).  
<form name="aTime"></form>
------------------^

Line 12, column 42: required attribute "TYPE" not specified (explain...).  
<SCRIPT LANGUAGE="JavaScript" SRC="ast.js">
------------------------------------------^

Line 14, column 64: document type does not allow element "BODY" here (explain...).  
...d="StartAstoniaTimer()" onunload="KillAstoniaTimer()">
--------------------------------------------------------^

Line 17, column 13: end tag for element "BODY" which is not open (explain...).  
</body></body>
-------------^

Line 18, column 5: document type does not allow element "HTML" here (explain...).  
<html>
-----^

Line 18, column 7: "HTML" not finished but document ended  
<ht...
-------^

Line 18, column 7: "HEAD" not finished but document ended  
<ht...
-------^

Line 18, column 7: "HTML" not finished but document ended  
<ht...
-------^

Maven




msg:1494245
 4:24 pm on Jan 29, 2004 (gmt 0)

Well I put it through the strict and got rid of most of the errors, all except 2, and it's still not working in netscape. I'm thinking frage it right about now lol. But I do appreciate all the help and advice, thanx all.

Here's the edited html:
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<style type="text/css">
A:link {COLOR: #00CC33;TEXT-DECORATION: none}
A:visited {COLOR: #00CC33; TEXT-DECORATION: none}
A:hover {COLOR: #00ff00; TEXT-DECORATION: none}

</style>
</head>

<BODY onload="StartAstoniaTimer()" onunload="KillAstoniaTimer()" text="#00CC33" bgColor="#000000">

<script src="header_data/ast.js" type="text/javascript"> </script>

<div id="AstonClock" style="background: #000000; position: absolute; color: ##00CC33; font-weight: bold; font-family: Latha ;"></div>

</body>
</html>

It look better in IE now but netscape won't touch it. *wonders why netscape has to be so difficult with html* :)

But I'm thinking it has something to do with the script itself. I've read somewhere (can't remember where) that netscape can't or won't handle the .innerHTML command but like I said I can't remember if this is right.

RonPK




msg:1494246
 6:16 pm on Jan 29, 2004 (gmt 0)

You're close. Change

AstonClock.innerHTML

into

document.getElementById('AstonClock').innerHTML

and remove the lines

AstonClock.document= "" + astoniaHours +":" + astoniaMinutes + " Aston Standard Time ";
clockID = setTimeout("UpdateAstoniaTimer()", 1000);

because they throw an error and seem useless to me ;)

It runs a bit fast though, your clock...

Maven




msg:1494247
 4:35 am on Feb 1, 2004 (gmt 0)

Hi, I did what you said and guess what? It stop working in IE and still doesn't work in Netscape. I changed it back with undo and now it won't work for either. Guess I messed something else up to. Maybe I'll just start from scratch, at this point it seems easier.

Also, yes your right, this clock is fast, an hour goes by every 5 min real time, :).

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved