开发者

Confirm message on browser page close

开发者 https://www.devze.com 2023-01-29 02:10 出处:网络
$(window).bind(\'beforeunload\', function() {return \'Are you shure?\';} ); 开发者_JS百科 How I must do that if user click CANCEL button page will be redirect to http://mypage.com?You cannot change w
$(window).bind('beforeunload', function() {return 'Are you shure?';} );
开发者_JS百科

How I must do that if user click CANCEL button page will be redirect to http://mypage.com?


You cannot change what happens when the user clicks one of the buttons in the dialog. This is intentional. Nobody wants to have web sites that mess with your navigation to that level.


yes you can u do

$(window).unload(function() {
    var answer = confirm("Are you sure?")
if (answer){
    alert("Bye bye!")
}else{
    alert("Thanks for sticking around!")
}

});

i just noticed that it wont prevent them from closing the window but it will show a confirmation when you close it >.<

it must be possible though since stackoverflow is doing it... try writing an answer and then close the windows you'll get a confirm box

0

精彩评论

暂无评论...
验证码 换一张
取 消