Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript and css menu...

    I had to copy a little bit of javascript to make my CSS work in IE. The css calls on a unsorted list to make a menu. In order to work in IE I had to name the top level <ul> to <ul id='nav'> and run the following script. This works fine for the first menu on the page, but none of the others work. There are an unlimited # of menus since each product listed on this page has a menu next to it that pops up the features for that product. Everything is databased fed.

    Is there any other javascript which will work on all the menus? Otherwise I'll have to write a php program to output the javascript based on whatever products are showing...

    thanks!



    Code:
    <script language="javascript">
    
    	startList1 = 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=startList1;
    </script>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,892
    Thanks
    202
    Thanked 2,528 Times in 2,506 Posts
    You appear to have multiple window.onload statements so each one overwrites the previous one.

    For an explanation and the solution see:-

    http://www.javascriptkit.com/javatut...iplejava.shtml


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •