JavaScript » Document » layers

Syntax:
document.layers["layerID"]

This property is an array containing references to all the Layer objects in the current document.

This property is an array containing references to all the Layer objects in the current document. These references are stored in the array in the order in which they are defined in the source code. The "layerID" argument is used to access items in the array and this can either be a string containing the layer name as defined within the <LAYER> or <ILAYER> tag in the HTML source, or an integer (with '0' being the first item in the array).

Note that when accessing the layers by their reference integer, as opposed to name, they are stored in the array in z-order (from back to front, with the back-most layer indexed as '0').

Examples

Code:
document.layers["layername1"]
document.layers["layername2"]
document.layers["layername3"]

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

Note that when accessing the layers by their reference integer, as opposed to name, they are stored in the array in z-order (from back to front, with the back-most layer indexed as '0').