Availability: |
| ||||
JavaScript syntax: | N | myLayerArray = myDocument.layers | |||
Object properties: | length |
Each item in this array corresponds to a <LAYER> tag in the document. This array also includes layers that are created in Netscape by setting the position attribute of an HTML <DIV> tag to absolute.
The layers in this array are ordered according to the order in which they appear in the document. Layers can be accessed associatively if they have been given an ID with the ID="..." or NAME="..." tag attribute. This means you can refer to an element whose ID is set to ABC by its unique name, either as document.ABC or document.layers["ABC"].
There is a bug in the layer management code in Netscape. If a <LAYER> tag is placed into the document without an ID="..." or NAME="..." HTML tag attribute, it will increment the length count for the LayerArray but an object will not be placed into the array.
Now if you try to enumerate through all the layers in the array using the length value, your enumeration loop will cause errors when it tries to access elements beyond the physical length of the array.
To avoid this, you should always add NAME="..." HTML tag attributes to the <LAYER> tags to ensure the layers are stored in the array. ID="..." HTML tags are important and helpful when trying to access objects in MSIE and in Netscape 6.0.
No longer supported in Netscape 6.0.
Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
length | 1.2 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
Prev | Home | Next |
Layer.zIndex | Up | LayerArray.length |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |