I am creating a simple navigation menu for the site. You create ul
with id menu
, and from there should be pretty simple. I have simple CSS to give all the li
correct background image, and then some jQuery to change the look li
when the user translates with the mouse. It works very well, but there is one problem. When a user clicks on a link directly, and does not click in the box around it, and then uses the back button in the browser, everything goes wrong. When the user wraps around this time, all the lithium goes completely empty, but it is beautiful as soon as the user leaves. Does anyone know what might cause this strange behavior? (Note that mousing over causes flickering from time to time li
, especially if it is one of the two bottomli
s. I thought this was normal, but maybe this can help diagnose the problem.)
<html>
<head>
<title>Menu Test</title>
<style type="text/css">
ul#menu{width: 185px; margin: auto; text-align: center; color: #fff; list-style-type: none;}
ul,li,h2{padding: 5px 0 0 0; margin: 0;}
li h2{height: 49px; background: url('top.png'); vertical-align: middle;}
li.link{height: 30px; background: url('link.png');}
li.link a{color: white; text-decoration: none;}
li.bottom{height: 25px; background: url('bottom.png');}
</style>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".link").mouseover(function(){
$(this).css({background: "url('file:///Users/J/Desktop/DHTML/Menu/linkselect.png')"});
})
$(".link").mouseout(function(){
$(this).css({background: "url('./link.png')"});
})
$(".link").click(function(){
window.location = $(this).find("a").attr("href");
})
})
</script>
</head>
<body>
<ul id="menu">
<li><h2>Menu</h2></li>
<li class="link"><a href="http://google.com/">Google</a></li>
<li class="link"><a href="http://norwegianrecycling.multiply.com/">Norwegian Recycling</a></li>
<li class="link"><a href="http://www.jquery.com/">jQuery</a></li>
<li class="link"><a href="http://www.apple.com/">Apple</a></li>
<li class="link"><a href="http://www.ubuntu.com">Ubuntu</a></li>
<li class="link"><a href="http://www.firefox.com/">Firefox</a></li>
<li class="link"><a href="http://www.youtube.com/">YouTube</a></li>
<li class="bottom"></li>
</ul>
</body>
</html>
source
share