Why is this not working in firefox, it works in IE and Opera. java script: function toggleMenu() { var oMenu = document.getElementById("item"); if(oMenu.style.display == "none") oMenu.style.display = "block"; else oMenu.style.display = "none"; } html: <ul> <li onclick="toggleMenu();">Menu</li> <li id="item" style="display:none;"> <ul> <li><a href="http://www.site1.com">site1</a></li> <li><a href="http://www.site2.com">site2</a></li> </ul> </li> </ul> Thanks.
It works for me too...So FF is not the issue. To anyone programming Javascript if you are not using FireBug then you are making coding so much harder on yourself than you have to. Just Google "FireBug".it is a free plugin for FF and works great. You can set break points, step through line by line..it will even show you what line the error is on. It has too many tools to mention but it has made writing JS much more effecient for me and many people I know. p.s. FF is superior to IE especially when performing complex client side scripts. The more complicated the slower IE renders.
I tried firebug and got this error: menusyk is not defined onclick(click clientX=0, clientY=0) Any idea what I should change?
Change whatever it is that is allowing a reference to be made to the non-existent object menusyk - or post more code.
This is the site in question. www.altomhelse.info if you got the possibility, could you please take a quick look at it?
The code you presented is not the same as that on your site. <p onclick="toggleMenu(menusyk);">Sykdommer</p> Code (markup): Should be <p onclick="toggleMenu('menusyk');">Sykdommer</p> Code (markup): function toggleMenu(menusyk) { var oMenu = document.getElementById("menusyk"); if(oMenu.style.display == "none") oMenu.style.display = "block"; else oMenu.style.display = "none"; } Code (markup): Should be function toggleMenu(menusyk) { var oMenu = document.getElementById(menusyk); if(oMenu.style.display == "none") oMenu.style.display = "block"; else oMenu.style.display = "none"; } Code (markup):