Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1187 When creating newLayer(), how can you give it a NAME or ID?

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.

Feedback on 'Q1187 When creating newLayer(), how can you give it a NAME or ID?'

©2018 Martin Webb