Forum Moderators: open

Message Too Old, No Replies

Drop Down Menus & Java

         

Latch

12:34 am on Jun 17, 2005 (gmt 0)

10+ Year Member



Hi guys, I'm new bla bla bla....anyway I'm trying to create some drop down menus but I can't seem to get the Java to work.

Here is my script

<script type=("text/javascript")>

startList = function() {
if (document.all &amp;&amp; document.getElementById) {
navRoot = document.getElementById("dmenu");
for (i=0; i &lt; navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}

window.onload=startList;
//-->
</script>

When I load the page I can see my two top menus but they do nothing...no drop down menu.

thanks in advance

rocknbil

1:05 am on Jun 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard Latch.

You're editing it in Dreamweaver, aren't you? :-)

startList = function() {
if (document.all &amp;&amp;document.getElementById) {
navRoot = document.getElementById("dmenu");
for (i=0; i &lt; navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}

Open it in an HTML or text editor, such as the super powerful application Notepad, turn the &amp;'s into & and the &lt;'s into < and see what happens.

By the way. JAVA is a compiled executable program that manifests itself on the web as an annoying applet. JAVASCRIPT is a scripted client side language enbedded in the page. They are very very different. <spank spank> :-)

Hope that works, have fun.

Latch

1:19 am on Jun 17, 2005 (gmt 0)

10+ Year Member



Thanks rocknbil, I made the changes (I'm a stoopid head) but it still does not appear to be working.

<body>

<ul class="topmenu" id="dmenu">
<li class="topmenuli"><a href="" class="topmenutitle">Home</a>
<ul class="submenuul">
<li class="submenuli"><a href="">Look ...</a></li>
<li class="submenuli"><a href="">Here ...</a></li>
<li class="submenuli"><a href="">Links ...</a></li>
<li class="submenuli"><a href="">Sitemap ...</a></li>
</ul>
</li>

<li class="topmenuli"><a href="" class="topmenutitle">Howdy</a>
<ul class="submenuul">
<li class="submenuli"><a href="">what ...</a></li>
<li class="submenuli"><a href="">how ...</a></li>
<li class="submenuli"><a href="">when ...</a></li>
<li class="submenuli"><a href="">where ...</a></li>
</ul>
</li>
</ul>
<div class="content">

<script type=("text/javascript")>

startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("dmenu");
for (i=0; i < navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}

window.onload=startList;
//-->
</script>

</body>

here is the body minus the CSS

Ta

rocknbil

1:33 am on Jun 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm 10 hrs here, seeing double, someone far wiser than I will be along soon, if not I will look again in am.

Latch

1:38 am on Jun 17, 2005 (gmt 0)

10+ Year Member



thanks for your time rocknbil

cheers

Latch

rocknbil

4:04 pm on Jun 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Surely someone can help Latch out here. :-)

Sathallrin

8:27 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



The CSS is what powers the menus... So that is what matters most.. the Javascript only forces this to work in IE.

Anyways, you have put the javascript inside of the body. For this script to work you have to put it inside of the <head> tags.

I have used this same script before, and it looks right as long as you do that.. and make sure you have the CSS right (with the style inside the <head> tags as well)

Latch

1:42 am on Jun 21, 2005 (gmt 0)

10+ Year Member



Thank for the help...I figured out where I was going wrong.