开发者

How to warn user not to leave the page? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

How can I ask a web user for confirmation if he really wants to leave the page?

Client/JS Framework for “Unsaved Data” Protect开发者_运维问答ion?

Like stackoverflow does on the ask page, when I click the close button or any other link on the site a dialog pops up asking if you're sure you want to navigate away from the page. How to do that in javascript or jQuery and can you customize the text in the box?


You want to listen to the onbeforeunload event:

window.onbeforeunload = function (e) {
  return 'Are you sure?';
};

https://developer.mozilla.org/en/DOM/window.onbeforeunload

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜