窗口警报后如何禁用浏览器后退按钮

时间:2019-03-11 05:53:59

标签: asp.net

   I need disable the browser back button after the window alert.

在page1.aspx中,我这样放置

 **$(document).ready(function () {
             function disableBack() { window.history.forward() }
             window.onload = disableBack();
             window.onpageshow = function (evt) { if (evt.persisted) disableBack() }
         });**

在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.

(如何防止在按下后退按钮时发出警报消息)

1 个答案:

答案 0 :(得分:2)

尝试一下:

jQuery(document).ready(function(){history.pushState(null, null, location.href);
    window.onpopstate = function () {
        history.go(1);
    };})