You are here: irt.org | FAQ | DHTML | Q1187 [ previous next ]
Try:
<html> <head> <script language="JavaScript"><!-- var myObjectLayer; function createLayer(layerName,layerWidth) { if (document.layers) { myObjectLayer = new Layer(layerWidth); myObjectLayer.name = layerName; } } function loaded() { createLayer('myName',100); alert(myObjectLayer.name); alert(document.layers['myName'].name); } //--></script> </head> <body onLoad="loaded()"> </body> </html>
On Netscape Navigator 4.5 on Linux, the setting of the layers name does not appear to work. Each time you create a layer Netscape gives it a name - for example: '__js_layer__10'. Each time you create another layer it appears as though the last number increase by one each time. It isn't (yet) possible to delete layers created this way - so treat this with caution, as you may find that the layers are not garbage collected once finished with, which might cause the browser to run out of memory.