如何在窗口警报后禁用浏览器后退按钮 [英] How to disable the browser back button after the window alert
本文介绍了如何在窗口警报后禁用浏览器后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I need disable the browser back button after the window alert.
in page1.aspx i put like this
After in Page2.aspx
I put alert message when button click.once close the alert message i press the back button.
same alert show when each click of back button.
(How to prevent the alert message when back button press)
我尝试过:
What I have tried:
**$(document).ready(function () {
function disableBack() { window.history.forward() }
window.onload = disableBack();
window.onpageshow = function (evt) { if (evt.persisted) disableBack() }
});**
推荐答案
(document).ready(function(){
function disableBack(){window.history.forward()}
window.onload = disableBack();
window.onpageshow = function(evt){if(evt.persisted)disableBack()}
}); **
(document).ready(function () { function disableBack() { window.history.forward() } window.onload = disableBack(); window.onpageshow = function (evt) { if (evt.persisted) disableBack() } });**
您无法禁用浏览器按钮,但可以阻止它使用。
以下代码可以帮到你 -
You cannot disable the Browser button, however you can prevent it to use.
Following code may help you -
<script type="text/javascript" >
function preventBack(){window.history.forward();}
setTimeout("preventBack()", 0);
window.onunload=function(){null};
</script>
这篇关于如何在窗口警报后禁用浏览器后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文