Forum Moderators: open

Message Too Old, No Replies

Problems with a dHTML menu

         

encyclo

6:29 pm on Sep 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've got a couple of questions based around the implementation of Blobfisk's dHTML menu from this thread:

[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.

Bernard Marx

7:37 pm on Sep 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not too sure what's going on in the script. I haven't looked it over closely

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.

encyclo

7:58 pm on Sep 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, it does seem to be related to my nested divs - I'm making some changes to the markup to get around the problem. As you said, it looks like it's because the script isn't finding the right divs. I'll post back if my adjusted markup doesn't do the trick.

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!)