禁用后退按钮无法在谷歌浏览器中工作 [英] disable back button not working in google chrome
问题描述
为防止用户访问上一页,我一直在使用以下javascript函数
To prevent the users from going to the previous page, i have been using the javascript function as follows
<script type"text/javascript">
function DisableBackButton() {
window.history.forward()
}
DisableBackButton();
window.onload = DisableBackButton;
window.onpageshow = function (evt) { if (evt.persisted) DisableBackButton() }
window.onunload = function () { void (0) }
<script>
它在ie9中工作得很满意
现在我发现在chrome和Firefx中,它无法阻止用户使用后退按钮。
我正在寻找修改代码或其他一些可以阻止用户使用后退按钮的代码
我不是说在注销时禁用后退按钮,而是在网站内的页面上使用后退按钮,这是必要的,因为当用户从一个页面转到另一个页面时,角色会发生变化。 />
欢迎任何形式的帮助
非常感谢
It has been working satisfactorily in ie9
Now i fiind that in chrome and Firefx, it fails to prevent users from using back button.
I am looking for modification in code or some other code that can prevent users from using back button
I am not talking of disabling back button on logout but it is all about using back button on pages within the site, which is necessitated because of change in role when user goes from one page to other.
Any kind of help would be welcome
Many thanks
推荐答案
测试以下几行:
Test the following lines :
<script type = "text/javascript" >
function preventBack(){window.history.forward();}
setTimeout("preventBack()", 0);
window.onunload=function(){null};
</script>
查看以下链接:
[ http://www.sawtoothsoftware.com/forum/1854/disabling-browser-back-button-chrome-previous-button [ ^ ]]
尝试
禁用 - 浏览器 - 后退 - 按钮 - 功能 - 使用 - JavaScript [ ^ ]
该演示似乎在Chrome中有效我试过的时候。
Try
Disable-Browser-Back-Button-Functionality-using-JavaScript[^]
The demo seems to be working in Chrome when I tried.
这篇关于禁用后退按钮无法在谷歌浏览器中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!