KingOfHeart Posted January 11, 2013 Share Posted January 11, 2013 I found this script online and while everything looks ok, for some reason the menu is not working. <html> <head> <title>MyMenu</title> <!--The CSS code.--> <style type="text/css" media="screen"> #mymenu { margin: 0; padding: 0; } #mymenu li { margin: 0; padding: 0; list-style: none; float: left; } #mymenu li a { display: block; margin: 0 1px 0 0; padding: 4px 10px; width: 80px; background: #bbbaaa; color: #ffffff; text-align: center; } #mymenu li a:hover { background: #aaddaa} #mymenu ul { position: absolute; visibility: hidden; margin: 0; padding: 0; background: #eeebdd; border: 1px solid #ffffff} #mymenu ul a { position: relative; display: block; margin: 0; padding: 5px 10px; width: 80px; text-align: left; background: #eeebdd; color: #000000; } #mymenu ul a:hover { background: #aaffaa; } </style> <!--The end of the CSS code.--> <!--The Javascript menu code.--> <script type="text/javascript"> //variables' declaration var timer = 0; var item = 0; //function for opening of submenu elements function openelement(num) { //checks whether there is an open submenu and makes it invisible if(item) item.style.visibility = 'hidden'; //shows the chosen submenu element item = document.getElementById(num); item.style.visibility = 'visible'; } // function for closing of submenu elements function closeelement() { //closes the open submenu elements and loads the timer with 500ms timer = window.setTimeout('if(item) item.style.visibility = 'hidden';',500); } //function for keeping the submenu loaded after the end of the 500 ms timer function keepsubmenu() { window.clearTimeout(timer); } //hides the visualized menu after clicking outside of its area and expiring of the loaded timer document.onclick = closeelement; </script> <!--END of CSS code--> </head> <body> <!--HTML code for the menu --> <ul id="mymenu"> <li><a href="http://siteground.com/">Home</a> </li> <li><a href="http://www.siteground.com/tutorials/" onmouseover="openelement('menu2')">Tutorials</a> <ul id="menu2" onmouseover="keepsubmenu()" onmouseout="closeelement()"> <a href="http://www.siteground.com/tutorials/cssbasics/index.htm">CSS</a> <a href="http://www.siteground.com/tutorials/flash/index.htm">Flash</a> </ul> </li> <li><a href="#" onmouseover="openelement('menu3')" onmouseout="closeelement()">More</a> <ul id="menu3" onmouseover="keepsubmenu()" onmouseout="closeelement()"> <a href="http://www.siteground.com/about_us.htm">About Us</a> <a href="http://www.siteground.com/contact_us.htm">Contact Us</a> </ul> </li> </ul> <div style="clear:both"></div> <!--the end of the HTML code for the menu --> </body> </html> http://king-trading.freeoda.com/TF2_quiz/trade_widow.html ---------------------------------- Also this entire fire can be turned into a javascript file, right? How do I call it in the body area? Quote Link to comment Share on other sites More sharing options...
cpd Posted January 11, 2013 Share Posted January 11, 2013 What have you done to debug it yourself? It would be helpful if you described what its meant to do as well. Saying "its broken", "please fix it" is hopeful at best. Quote Link to comment Share on other sites More sharing options...
KingOfHeart Posted January 11, 2013 Author Share Posted January 11, 2013 I hover over the menu with my mouse, all it does is highlight the main buttons. Nothing drops down so all I see is "home", "tutorials", and "more" I don't see the rest. No CSS, no tutorial, no About us, and no contact us.. I'm still a newbie so can't really debug..all I plan on doing is changing link names, playing with the x/y, just taking it one step at a time and see how custom I can make it. Quote Link to comment Share on other sites More sharing options...
cpd Posted January 11, 2013 Share Posted January 11, 2013 What do you understand about the script above specifically? Quote Link to comment Share on other sites More sharing options...
KingOfHeart Posted January 11, 2013 Author Share Posted January 11, 2013 I understand what the functions are suppose to do. I haven't worked with it enough to just write my own script. Answer me this, do you yourself see a major fault with the script? If it's simple, just tell me please. If it's complicated..well, I'll just google for more menu scripts and just fiddle with it. Quote Link to comment Share on other sites More sharing options...
cpd Posted January 11, 2013 Share Posted January 11, 2013 Your mark-up looks wrong as you have no list item tags in your sub unordered list tags. If you can't be bothered understanding the script just use google to find another. Its a waste of everybodies time explaining what's wrong. Quote Link to comment Share on other sites More sharing options...
White_Lily Posted January 12, 2013 Share Posted January 12, 2013 You could also just learn jQuery and write one yourself. That way you will understand 100% of it, be able to edit and debug it, and you will know what to edit and what not to edit when it comes to making particular changes. What I can do is have a go at making a small menu (like yours) myself with code that I will write, and post it here if I succeed and find its cross-browser compatible. Okay? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.