开发者

Confirm message on browser page close

$(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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜