Netscape’s Javascript Documentation From 1999 (document.layers!)

Don’t ask why I’m poking around the wayback machine (that would spoil the surprise,) but if you’ve been around as long as I have and want to reminisce, or never got to experience Web 1.0 as a developer and want to see what all the complaints are about, you should really take a look at Netscape’s JavaScript documentation from 1999.

Here’s one that will confuse the hell out of anyone who started doing this after maybe 2003:

document.layers
The layers property is an array containing an entry for each layer within the document.

Property of

document

Implemented in

JavaScript 1.2

Description

You can refer to the layers in your code by using the layers array. This array contains an entry for each Layer object (LAYER or ILAYER tag) in a document; these entries are in source order. For example, if a document contains three layers whose NAME attributes are layer1, layer2, and layer3, you can refer to the objects in the layers array either as:

document.layers["layer1"]
document.layers["layer2"]
document.layers["layer3"]

or as:

document.layers[0]
document.layers[1]
document.layers[2]

When accessed by integer index, array elements appear in z-order from back to front, where 0 is the bottommost layer and higher layers are indexed by consecutive integers. The index of a layer is not the same as its zIndex property, as the latter does not necessarily enumerate layers with consecutive integers. Adjacent layers can have the same zIndex property values.

These are valid ways of accessing layer objects:

document.layerName
document.layers[index]
document.layers["layerName"]
// example of using layers property to access nested layers:
document.layers["parentlayer"].layers["childlayer"]

Elements of a layers array are JavaScript objects that cannot be set by assignment, though their properties can be set. For example, the statement

document.layers[0]="music"

is invalid (and ignored) because it attempts to alter the layers array. However, the properties of the objects in the array readable and some are writable. For example, the statement

document.layers["suspect1"].left = 100;

is valid. This sets the layer’s horizontal position to 100. The following example sets the background color to blue for the layer bluehouse which is nested in the layer houses.

document.layers["houses"].layers["bluehouse"].bgColor="blue";

To obtain the number of layers in a document, use the length property: document.layers.length.

Have you ever heard someone say the phrase “div layer” and wondered what the heck they were talking about? Now you know. Netscape had a parallel concept to DIVs that they called LAYERs and for a while you had to deal with these two competing technologies in ways that were generally unpleasant (so unpleasant I forget the specifics.) This two-pronged approach was so ingrained in the way we looked at things we made a hybrid term, “div layer” to describe them.

I look back and am amazed at the fact that we got anything at all done back then.

Leave a Reply

Your email address will not be published. Required fields are marked *