Initialization of DynLayers

The DynLayer can be applied to any layer using this general format:

objectName = new DynLayer(id,nestref,iframe)
Where:
objectName
Name of the object - how you will reference the DynLayer object.
id
ID of the layer to which this DynLayer is being applied to, this cannot be the same as the objectName
nestref
Nested reference to that layer - only needed when the layer is nested within other layer
iframe
Name of the iframe that the layer is contained. This is used when you need to manipulate a layer inside an IFrame. Currently IFrame is only a feature of IE4.

Simple Layer Example:

Let's say you have a very simple layer with this structure:

<STYLE>
#mylayerDiv {position:absolute; left:30; top:50;}
</STYLE>

<DIV ID="mylayerDiv"></DIV>

To initialize 'mylayerDiv', your javascript will be:

mylayer = new DynLayer('mylayerDiv')

Notice how I append the 'Div' extension on the ID of the layer. I do this is because the name of the object cannot be the same as the ID of the layer. It's just a nice way to keep your variables separate.

Nested Layer Example:

<DIV ID="myparentDiv">
	<DIV ID="mylayerDiv"></DIV>
</DIV>

To initialize 'mylayerDiv':

mylayer = new DynLayer('mylayerDiv','myparentDiv')

Notice the name of the parent layer is passed for the nestref argument.

Multiple Nesting:

<DIV ID="myparent1Div">
	<DIV ID="myparent2Div">
		<DIV ID="mylayerDiv"></DIV>
	</DIV>
</DIV>

If the layer is nested multiple times you must pass the names of all layers in that hierarchy separated by '.document.':

mylayer = new DynLayer('mylayer','myparent1Div.document.myparent2')

IFrame Initialization:

If for IE the layer is inside the IFrame named "myiframe" and not nested, you'd write:

if (ie4) mylayer = new DynLayer('mylayer',null,'myiframe')

Initialization Demo:

View dynlayer-initialization1.html for an example showing various initializations.

Also Read: DynLayerInit() Function which you can call to automatically define DynLayers.

The Dynamic Layer Object API

Extending the DynLayer

Home Next Lesson: Geometric Objects
copyright 1998 Dan Steinman