窗口popstate事件在野生动物园中不起作用 [英] window popstate event not working in safari
本文介绍了窗口popstate事件在野生动物园中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试通过以下代码禁用浏览器后退按钮:
I have tried to disable browser back button by this code :
<script>
//disable back button
history.pushState(null, null, ' ');
window.addEventListener('popstate', function () {
history.pushState(null, null, ' ');
});
</script>
它可在 Chrome , Mozila , IE10 中使用,但不适用于Safari(5.x).
有人在跨浏览器之前实现了这一目标吗?
It works in Chrome, Mozila, IE10, but does not work for safari(5.x).
Has anyone achieved this before crossbrowser ?
推荐答案
history.pushState(null, null, Url);
window.addEventListener('popstate', function(event) {
history.pushState(null, null, Url);
});
这工作正常,但我也有另一个适用于野生动物园浏览器的解决方案:
this work fine but I also have another solution for safari browser:
history.replaceState(null, null, 'url');
history.pushState(null, null, 'url');
这篇关于窗口popstate事件在野生动物园中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文