Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making the sub-options hide when making a css dropdown menu 2

Status
Not open for further replies.

krigbert

Programmer
Jun 2, 2005
95
NO
I'm sort-of following a tutorial from "a list apart"for making css-dropdowns ( ), but even though I've written

Code:
	#nav li ul {
	    display: none;
    }

The sub options simply won't dissappear.

Also, how can you make the hover state of one thing affect something else?
 
I've no idea why but this works

Code:
	 	  startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		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;

As far as I could tell it was the same as your javascript. Or at least any differences didn't seem to make a difference to it not working.
But when I use the script from a menu I have then your's works fine.

Foamcow Heavy Industries - Web design and ranting
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
I wonder what possesses people to make those animated gifs. Do you just get up in the morning and think, "You know what web design r
 
This is getting wierder by every post. The code above worked in my minimalistic test document, but not in the actual document. So I removed line by line to test what was wrong.

When I removed the
Code:
onLoad="MM_preloadImages('images/Production.png','images/Development.png','images/send.png','images/print.png')"
from the <body> it suddenly worked. This is a bit dreamweaver puts in to preload images. The function MM_preloadImages looks like this:

Code:
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

You have any idea why these two functions clash?
 
Can you only have 1 onload event?

There is an onload event at the end of my script.
Try adding the window.onload command to the onload event in the body tag instead.

Foamcow Heavy Industries - Web design and ranting
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
I wonder what possesses people to make those animated gifs. Do you just get up in the morning and think, "You know what web design r
 
You mean like
Code:
<body onLoad="startList">

That doesn't work.
 
Changing the window.onload to this worked:
Code:
window.onload=startList, MM_preloadImages('images/Productiono.png','images/Developmento.png','images/sendo.png','images/printo.png');

Though I can't know for sure if the images preloaded since I don't have the site online yet.
 
i'd try something like:

Code:
<body onLoad="startList();MM_preloadImages('images/Productiono.png','images/Developmento.png','images/sendo.png','images/printo.png');">

Although I'm really rusty regarding javascript.

Foamcow Heavy Industries - Web design and ranting
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
I wonder what possesses people to make those animated gifs. Do you just get up in the morning and think, "You know what web design r
 
And it works. Good to get that out of the way. Cheers :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top