Forum Moderators: open

Message Too Old, No Replies

JavaScript Jumpstart #3 - dHTML menu (old post)

Couple of questions on making the above work

         

Beau

9:52 am on Dec 10, 2004 (gmt 0)

10+ Year Member



Hi,

in my searchs for a menu system that a newbie such as myself could play around with I found the above post - [webmasterworld.com...] - with a script from BlobFisk.

I have tried to implement it but can't seem to get it to work so have a few questions:

1. I have inserted all of the javascript into an external .js file as is - with the exception of inserting the layers I want to be subject to this into the hideAll() function.
Is this correct or are there other areas I need to modify?

2. My layers are set up in an external CSS file. Should I be putting any type of visibility statement into the layers that I'm wanting to use in the menu?

3. In the HTML I have pasted the onMouseOver script into the <a> tag of the div that I want to trigger the next line of the menu. I have pasted as is except to insert the name of the div I want to be shown into the showlayer() function.
Do I need to modify anything else?

Extracts from my code:
CSS:
#m1{ position: absolute; left: 130px; top: 90px; visibility: visible; overflow: hidden; }
//this is the first item in the top line navigation//

#m1s{position: absolute; left: 130px; top: 110px;}
//this is the second line navigation that should be triggered when the user mouses over m1//

HTML:
<div id="m1"><a onMouseOver="hideAll(); showlayer('m1s'); stopTime()" onMouseOut="startTime();"></a>menu m1 text</div>
<div id="m1s">menu m1s text</div>

Any ideas or pointers to other tutorials much appreciated. Many thanks,

Beau

orion_rus

7:28 pm on Dec 10, 2004 (gmt 0)

10+ Year Member



All what u right not helps u to make a menu. No difference would be if it is an external file or inner function. Because u are newbie i suggest u to make all in the one file (css jscript and html). To teach u how menus making. I suggest u to find some tutorial about this or make something like this in the beggining.

<head>
function ShowMenu(menuid)
{newmenu=document.getElementById(menuid);
newmenu.style.display="block";
}
</head>
<body>
<div id="menu" style="display:none">
Hi, i'm ur menu
</div>
<div onclick="ShowMenu('menu');">
Show me menu!
</div>
</body>

Step by step u recongnize how to making hard dynamically menus
Good luck to you

HelpAN00b

2:27 am on Dec 12, 2004 (gmt 0)

10+ Year Member



hey, your menu system looks like it would be something that i could really use. Unfortunatley the hidemenu function i tried to write does not like to work. here is my source...i hope i didn't mess it up beyond recognition.

<head>
<script type=text/javascript>
function ShowMenu(menuid)
{
newmenu=document.getElementById(menuid);
newmenu.style.display="block";
}
function HideMenu(menuid)
{
hidemenu=document.getElementByID(menuid);
hidemenu.style.display="none";
}
</script>
</head>
<body>

<div onmouseover="ShowMenu('menu');" onmouseout="HideMenu('menu');">
Show me menu!
</div>
<div id="menu" style="display:none">
Hi, i'm your menu
</div>
</body>

HelpAN00b

2:32 am on Dec 12, 2004 (gmt 0)

10+ Year Member



hello, again. i apologize for the double post, but i have solved my problem by reusing the newmenu variable.

orion_rus

7:49 am on Dec 12, 2004 (gmt 0)

10+ Year Member



great i think it's more interesting to write your own menu. And to solve any problems in it at any time. Because it's your OWN.
I suggest you to make following step in it. All menus consists of points.
You must make <div> element with <a> tag.
it would be seen like this:

<head>
.....
<style type="text/css">
menucaption
{text-decorations:none}
a.menucaption
{color:#000000;}
a.menucaption:hover
{color:#FF0000;}
</style>
</head>
<body>
....
<div id='menu' style='display:none' onmousever onmouseout>
<div class="menucaption"><a class="menucaption" href="">Item 1</a></div>
<div class="menucaption"><a class="menucaption" href="">Item 2</a></div>
<div class="menucaption"><a class="menucaption" href="">Item 3</a></div>
</div>

this class would be describes your menu items. Hover effect works so: when u mouseover to <a> elem style of <a> switched to style:hover (how i describe in the <style>. It's the basics)
Good luck)