我创建了一个从页面外部滑入的菜单。问题是,当您单击菜单中的某个项目并加载新页面时,新页面会在菜单关闭的情况下加载。有没有办法告诉浏览器在新页面加载后保持菜单打开?
这是打开菜单的代码
<script>
$(document).ready(function(){
$("#closeIcon").hide()
$(".left").width('0%');
$(".right").width('100%');
});
$(document).ready(function(){
$("#menuIcon").click(function(){
$(".left").animate({width:'10%'}, "500");
$(".right").animate({width:'90%'}, "500");
$("#nav").animate({
left: '30%',
}, "500" );
$("#menuIcon").fadeOut(500)
$("#closeIcon").fadeIn(500)
});
});
$(document).ready(function(){
$("#closeIcon").click(function(){
$(".left").animate({width:'0%'}, "500");
$(".right").animate({width:'100%'}, "500");
$("#nav").animate({
left: '0',
}, "500" );
$("#menuIcon").fadeIn(500)
$("#closeIcon").fadeOut(500)
});
});
</script>
这是html:
<html>
<div id="menu" >
<div id="menuIcon">
<a href="javascript: void(0)">
<img src="images/menuIcon.png">
</a>
</div>
<div id="closeIcon">
<a href="javascript: void(0)">
<img src="images/closeIcon.png">
</a>
</div>
</div>
</html>
<div class="left">
<div id="nav">
<div id="accordion">
</div> <!--ends accordion-->
</div>
</div>
<div class="right">
<div id="content">
</div><!--ends content-->
</div><!--ends right-->