Click to See Complete Forum and Search --> : Pulling my hair out..


WolfShade
01-13-2003, 10:42 AM
Okay, it works GREAT in IE5, IE5.5, & IE6. Can't get anything from Netscape 4.79 OR 6.2.3. It's a simple clock script that does not use a text box to display in. Here's what I have, so far.

In a table cell, I have the following code:
<span id="datedisplay" style="position:absolute;left:11;top:15;"></span>

Immediately after that line, I placed the Javascript function. I also had it within the HEAD tags, and I moved it to after the BODY close tag, it didn't make any difference when tested. I won't post the WHOLE script, as it's kinda lengthy, but here's the important bits:

<SCRIPT language="JavaScript" TYPE="text/javascript">
<!-- Hide from NonJS browsers
function show() {
[all variables go here]

datedisp = jhours + ":" + jminutes + ":" + jseconds + dn + " " + jday + " " + jmonth + " " + jdayt + " " + jyear + "";
if (document.all) {
datedisplay.innerHTML=datedisp;
}
else {
x = document.layers["datedisplay"];
dd = '<P class="clocktextred">'+datedisp+'</p>';
x.document.write(dd);
x.document.close();
}
setTimeout("show();",1000);
}
show();

// -->
</script>

Someone told me that Netscape 4 doesn't handle layers, very well. Is there something else that I should be using, instead? Something that will do the same thing as IE's innerHTML?

WolfShade

khalidali63
01-13-2003, 11:12 AM
Well just looking at the code you posted,I can tell you this much that your code will never work with NS6+ browsers.
Because in NS6+ brwosers you have to reference a div tags id using the following line
document.getElementById("divId");
for ns4+ I am not sure why its not working.may be if you post a link to your page in question or put code here.

Khalid

WolfShade
01-13-2003, 12:03 PM
Originally posted by khalidali63
Well just looking at the code you posted,I can tell you this much that your code will never work with NS6+ browsers.
Because in NS6+ brwosers you have to reference a div tags id using the following line
document.getElementById("divId");
for ns4+ I am not sure why its not working.may be if you post a link to your page in question or put code here.

Khalid

I wanted to make sure it would work in 4.x before setting it up for 6+.

Thing is, I did a search on google for this, and every page I found says that document.layers[id].document.write(x) is the proper NN4.x format; yet the javascript console will say that document.layers.datedisplay has no properties. (Hmm.. think I should have posted that, earlier? :) )

Once it works in 4.79, I'll set it up for NN6+.

WolfShade

khalidali63
01-13-2003, 12:13 PM
make sure datedisplay is properly defined in the HTML section of the code.

WolfShade
01-13-2003, 04:20 PM
Originally posted by khalidali63
make sure datedisplay is properly defined in the HTML section of the code.

I've got the following in a table cell:
<span id="datedisplay" style="position:absolute;left:11;top:15;"></span>

Shouldn't that be enough to define it? Do I need to do something else to make the browser 'see' it?

WolfShade

khalidali63
01-13-2003, 05:16 PM
Well its not upto us to decide whats enough for NS4+ browesers to see a id attribute,
Anyways,
I have found and fixed the bug in your code that was stopping NS to see the datadisplay span tag.

cheers
Khalid

<span id="datedisplay" style="position:absolute;left:11;top:15;"></span>
<SCRIPT language="JavaScript" TYPE="text/javascript">
<!-- Hide from NonJS browsers
function show() {

datedisp = new Date();//jhours + ":" + jminutes + ":" + jseconds + dn + " " + jday + " " + jmonth + " " + jdayt + " " + jyear + "";
if (document.all) {
datedisplay.innerHTML=datedisp;
}else {
x = document.layers["datedisplay"];
dd = '<P class="clocktextred">'+datedisp+'</p>';
x.document.open();
x.document.write(dd);
x.document.close();
}
setTimeout("show();",1000);
}
window.onload = show;
// -->
</script>