mikenl Posted August 25, 2007 Share Posted August 25, 2007 I'm trying to make a menu which stays highlighted onclick AND hovers the other menu items on mouseover... The menu is in a frame. I have something like this now - am just trying stuff. The first function works fine (onclick highlight), the second gives problems... Anyone has a clue how to make this work? function navbar(id) { for (i=1;i<=6;i++) { var navname = 'nav'+i; var navStyle = document.getElementById(navname).style; navStyle.background=(id==navname)?'url(gfx/tab.gif) 0 -31px':'url(gfx/tab.gif)'; navStyle.color=(id==navname)?'#000':'#214d8c'; } } function hoverbar(id) { for (i=1;i<=6;i++) { var hovername = 'nav'+i; var hoverStyle = document.getElementById(hovername).style; if (hoverStyle.background==(id==hovername)=='url(gfx/tab.gif) 0 -31px'); { hoverStyle.background=(id==hovername)='url(gfx/tab.gif) 0 -31px'; hoverStyle.color=(id==hovername)='#000'; } } } Menu items look like this: <ul> <li><a href="link1.php" id="nav2" target="mainFrame" onClick="navbar('nav1');" onmouseover="hoverbar('nav1');">TEXT 1</a></li> <li><a href="link2.php" id="nav3" target="mainFrame" onClick="navbar('nav2');" onmouseover="hoverbar('nav2');">TEXT2</a></li> etc... </ul> 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.