【发布时间】:2015-02-25 18:36:25
【问题描述】:
在这个例子中,我们设法使后退按钮工作,但前进按钮似乎是一个问题,当按下前进按钮时,#modal 应该重新出现但它没有。有什么办法解决吗?
$(window).bind('popstate', function() {
$('#modal').hide();
});
$(".view").click(function() {
history.pushState(null, null, null);
$("#modal").show();
});
#modal {
position: relative;
display: none;
height: 100px;
width: 100px;
background-color: grey
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<button class="view">Click</button>
<div id="modal"></div>
谢谢!
【问题讨论】:
-
什么是 history.pushState(null, null, null);正在做?我看不到后退按钮或前进按钮。从代码中不清楚你在做什么。
标签: javascript jquery html html5-history