Click to See Complete Forum and Search --> : z-index from script to style


Wildcat
10-22-2003, 11:21 PM
I had downloaded one of the menu scripts from dynamicdrive.com, and I was trying to edit it so the menu would be willing to move underneath an image. The menu itself is blank on that section, and I tried to set the z-index of the image higher than the menu. However, the instructions provided give me an error in IE, and I was wondering if anyone here could help me out.


function getzIndex(layer) {

if (isMinNS4)
return layer.zIndex;
if (isMinIE4)
return layer.style.zIndex;

return -1;
}

function setzIndex(layer, z) {

if (isMinNS4)
layer.zIndex = z;
if (isMinIE4)
layer.style.zIndex = z;
}


That's the javascript in the external file. They told me I could change z-index by using


setzIndex(z)


so I used


setzIndex(1)


and set the image's z-index at 10 through stylesheets. However, the browser tells me "script is null or not an object" when I refresh the page, and insists on sticking the image underneath the menu. I'd appreciate any help, since this script is a bit beyond my Javascripting knowledge.

gil davis
10-23-2003, 05:55 AM
This isn't right:
setzIndex(z)
It should be:
setzIndex(layer, z)
and "layer" has to be the object, not just its name.

Wildcat
10-23-2003, 11:58 AM
Yeah, that's what I kindof thought. How do I make the image "layer"? Do I name it and stick the name in there, or what?