DynLayerInit() Function

Note: This function is now manditory. Even if you do not specifically call this function, the first time you assign a DynLayer, the DynLayerInit() function will automatically be called to assign whatever layers have a "Div" in their ID, as well as find all the nestref's for all layers in the page. So you don't necessarily ever have to call this function manually unless you don't plan on assigning any DynLayers yourself.

The DynLayerInit() function is used to initialize all your DynLayers at once automatically and is used by the DynLayer to take care of all nested heirarchy work for Netscape. The way it works is by sniffing through the names of all layers in the page. Any layers that contain an ID with a "Div" extension on it will be automtically assigned to a DynLayer. This function does not apply to layers inside Frames or even more advanced circumstances like external files or dynamically generated layers.

As noted, you only have to call the DynLayerInit() function manually if you do not have any layers that don't have a "Div" extension, and therefore won't need to manually define any layers at all. Just call the function in your default init() function:

function init() {
	DynLayerInit()
}

As long as you follow my lead of appending a "Div" to the names of your layers it will do the same thing as defining your layers manually. For example say you had a layer named "blueDiv" like this:

<STYLE TYPE="text/css">
#blueDiv {position:absolute; left:50; top:50;}
</STYLE>
<DIV ID="blueDiv"></DIV>

The DynLayerInit() function will automatically execute the code to initialize it:

blue = new DynLayer("blueDiv")

So any layers that have a "Div" extension never have to be initialized manually. This includes nested layers. Note though, layers that are contained in external files, different frames must be manually assigned.

Also note, the names of your layers may be something other than with the "Div" extension. However, DynLayerInit() will not automatically define these, although it will find it's nestref value so that you don't have to pass it it.

Example: dynlayer-dynlayerinit1.html [source]

The Dynamic Layer Object API

Home Next Lesson: DynLayer Properties
copyright 1998 Dan Steinman