方法一:
<script>
var url = document.referrer; //获取上一页URL
// i不能设置过大,否则会导致浏览器崩溃,如设置1000000
for(i=0;i<50;i++){
history.pushState({}, 0,''); //不刷新当前页面的情况下添加浏览器历史记录
}
isclick = false;
setInterval(function () {
if (isclick == false) {
history.pushState('', '', '');
} else {
isclick = false;
}
}, 100);
</script>
方法二:
<script type="text/javascript">
$(function() {
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
window.history.pushState('forward', null, '#');
window.history.forward(1);
});
}
window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
window.history.forward(1);
})
</script>
方法三:
<script type="text/javascript">
jQuery(document).ready(function ($) {
if (window.history && window.history.pushState) {
$(window).on('popstate', function () {
window.history.forward(1);
});
}
});
</script>