Forum Moderators: open
Here is my script
<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>
When I load the page I can see my two top menus but they do nothing...no drop down menu.
thanks in advance
You're editing it in Dreamweaver, aren't you? :-)
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", "");
}
}
}
}
}
Open it in an HTML or text editor, such as the super powerful application Notepad, turn the &'s into & and the <'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.
<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
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)