November 26, 2000 - DHTML Elements in Netscape 6 | WebReference

November 26, 2000 - DHTML Elements in Netscape 6

Yehuda Shiran November 26, 2000
DHTML Elements in Netscape 6
Tips: November 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

When you programmed DHTML elements in Internet Explorer and Netscape Navigator, you probably used the DIV element for the former, and the LAYER element for the latter. To change the position and visibility of a DHTML element in Internet Explorer, you probably wrote something like this in the HTML:

<DIV ID="foo" STYLE="position:absolute; left:-200; top:-100; visibility:"hidden">This is the IE foo</DIV>

and a script like this to change the element location and visibility:

document.all.foo.style.left = 200;
document.all.foo.style.top = 100;
document.all.foo.style.visibility = "visible";

Similarly, in Netscape Navigator you would use the LAYER element. You would put a line like this in the HTML page:

<LAYER NAME="foo" LEFT=-200 TOP=-100 VISIBILITY="hidden">This is the NN foo</LAYER>

and a script like this to change the element location and visibility:

document.layers.foo.left = 200;
document.layers.foo.top = 100;
document.layers.foo.visibility = "visible"

In Netscape 6, you would use the IE's HTML syntax for a DIV element:

<DIV ID="foo" STYLE="position:absolut; left:-200; top:-100; visibility:"hidden">This is the N6 foo</DIV>

but you would use the document.getElementById() method to reference this element:

document.getElementById("foo").style.left = 200;
document.getElementById("foo").style.top = 100;
document.getElementById("foo").style.visibility = "visible";