Click to See Complete Forum and Search --> : Get ID from layer


simonhorne
01-18-2003, 02:35 PM
Hi

I have some DHTML code the does some moving layers about.

I have the following code for example that moves a layer from top of the scree to the bottom

<DIV ALIGN="center" ID="Navbar1" onmouseout="javascript:MouseOutContext(Navbar1); " onmouseover="javascript:MouseOverContext(Navbar1); "><A HREF="javascript:slideout(LAYER1)" class="done">click this</A></DIV>

Where LAYER1 is another layer based on a style #LAYER1
My slideout function then as you is passed the the LAYER1 object reference

function slideout(WHICHLAYER) {

/*code that does the layer move*/

}


What I want to know is can I get the ID property back from the layer object again, as in the slideout function I want to store this away somewhere. I've tried WHICHLAYER.id, WHICHLAYER.name, whichlayer.style

but all are returned as undefined is there a reverse GETELEMENTBYID function I can use? Sorry if some of my terminology is wrong here, but my limited very JS knowledge is self taught

Thanks

khalidali63
01-18-2003, 02:46 PM
typically

var nLayer=document.layers["layerId"];
or
var nLayer=document.layerId;

gives you access to layer object and its attributes
nLayer.id will give you the id name.

NS forces a developer to follow the almost strict coding standards,please make sure that the layer object is initialized as it should be or post your entire code here so that some one can take a look.

cheers

Khalid

khalidali63
01-18-2003, 03:10 PM
the original post actually refered layers
and I thought it was obvious that document.layers is and was only supported in NS 4+ or lower.
NS 6 is completely different structure,apparently it was not.

Khalid

simonhorne
01-18-2003, 03:27 PM
Thanks Dave,

This looks like the answer I need. What I'm doing is probably a little odd anyway since I don't really understand Javascript that well and I'm sure that there are easier ways to get my end result.

The reason I want to store away the ID is that I have a frames structure. The layers have links to other pages that are displayed in the same frame as this. The problem being that when you hit the browser back button, the page is reloaded without the layer that had the original link on top. It's an Aesthetic thing but annoying

Cheers