Forum Moderators: open
[webmasterworld.com...]
I've not played with such a script before (and I'm allergic to such menus as a rule, but what the client wants...)
I've included the script as explained in the thread, and have the following markup:
<div class="nav2" onMouseOver="hideAll(); showLayer('pres'); stopTime()" onMouseOut="startTime();"><a href="/index.php?page=Presentation">Présentation</a>
<!-- popout 1 -->
<div name="pres" id="pres">
<a href="#">Link1</a><br>
<a href="#">Link2</a><br>
<a href="#">Link3</a></div>
<!-- end popout 1 -->
</div> Trouble is, the "pres" div takes up space in the menu when invisible, but if I set it to display:none; it never appears at all on mouseover. What's more, there is no sign of it working in NN4 - I get the error "document.layers.pres has no properties".
I have onload="init();" on the body element, but the layers are visible unless I add hideAll(); to the same onload - is this normal?
OK, the stupid question is how do I get the layer to take up no space and still appear on mouseover? Do I need to use document.write or am I just being thick here and I've forgotten something obvious?
Thanks for any insight on this from a poor old javascript newbie.
Here's a few NS4 pointers though:
- I believe you can only reference positioned <div> elements. position:relative (0,0) is OK.
- Each "layer" (positioned div) is a separate document, so to reference layer, id="two" that is nested inside layer, id="one", you need:
document.layers.one.document.layers.two - Some (all?) versions of NS4 have trouble switching on/off
display dynamically.
Thanks for putting me on the right track! (Since posting, I've talked to the client and I think he's going to go for a server-side solution anyway - so hopefully I won't need this!)