In pre-Gecko Netscape, there's a supplement for not having
:
Each
has a
object.
This is just like the normal
object that you begin with.
You have methods like
and
.
Like this:
Code:
document.layers.myLayer.document.write('<html></html>');
document.layers.myLayer.document.close();
Layers, however, are not capable of resizing on their own (and they normally don't have scrollbars).
If the content grows larger than it was when the layer originated, then you have to resize it manually:
Code:
document.layers.myLayer.resizeTo(document.layers.myLayer.document.width,
document.layers.myLayer.document.height);
Then, if you have content that is below the layer that should appear as if it were directly below the layer (As in, when the layer resizes, it moves along with the layer), the content below must be in a layer of its own so you can move it up and down -- which you must also do manually:
Code:
document.layers.myLayer2.top=document.layers.myLayer.document.height;
Or, if the moving layer is joined by the side:
Code:
document.layers.myLayer2.left=document.layers.myLayer.document.width;
The above is assuming that
is at the coordinates 0,0 in the layer it is nested inside.
and
access the document's dimentions -- much like DOM1's
Code:
document.body.scrollHeight
and
Code:
document.body.scrollWidth
.
It is how much the document actually takes, not how much space is allocated for it.
Far less convenient than simply having
on a non-absolutely-positioned DIV, but at least you can still alter your contents in Netscape :-\.
You can access a layer's visibility like this:
Code:
document.layers.myLayer.visibility
A note about DOM1-accepting browsers:
One convenient thing in normal CSS is that you have the
attribute -- little known, but very nice (except that pre-Gecko Netscape has no equivalent. In pre-Gecko NS, you
can set a div's style to display:none, but you can't access it using JavaScript). It acts much like
, but if the object is being hidden, it also takes up no space on the page:
IE:
Code:
document.all.myDiv.style.display="block";
document.all.myDiv.style.display="inline";
document.all.myDiv.style.display="none";
DOM1:
Code:
document.getElementById('myDiv').style.display="block";
document.getElementById('myDiv').style.display="inline";
document.getElementById('myDiv').style.display="none";
In case you didn't know, an example of a block is a
; it takes up the entire screen from left to right. An example of inline is the
, which sits in the page just like normal text. An example of none is when you put some whitespace on your page ;-). When you tell your object to display none, it will
take up absolutely no space on the page. Unless the object you're trying to manipulate is absolutely positioned, this property is quite useful.
Ah yes... You
cannot alter the contents of an
, as it will cause the rest of the page to disappear because of bugs in Netscape that were never fixed.
And another thing, if you have images within layers, you must access them
through the layer:
Code:
document.layers.myLayer.document.images
Rather than simply accessing the images through the main
object.
A note, Mozilla (NS 6) does not support the
property. It does, however, support
That's just about all of the things that you would really want to know about DHTML coding for Netscape.
Click here if you want a nice big list of the (very few) properties and methods that pre-Gecko Netscape allows with its objects:
Real friends let friends drive as minors. Will you be my friend?