javascript - Confirm window close - Stack Overflow

I am creating an HTML printable quiz and test maker and I would like to confirm "Are you sure you

I am creating an HTML printable quiz and test maker and I would like to confirm "Are you sure you want to close this window?" when the user attempts to close the window. If they click ok it closes, but if they click cancel it does not.

I need this to work in IE and Chrome.

I am creating an HTML printable quiz and test maker and I would like to confirm "Are you sure you want to close this window?" when the user attempts to close the window. If they click ok it closes, but if they click cancel it does not.

I need this to work in IE and Chrome.

Share Improve this question edited Dec 11, 2013 at 6:54 Jonathan Leffler 756k145 gold badges951 silver badges1.3k bronze badges asked Mar 22, 2013 at 20:37 Dustin HDustin H 852 silver badges8 bronze badges 1
  • 4 You're probably looking for developer.mozilla/en-US/docs/DOM/window.onbeforeunload – j08691 Commented Mar 22, 2013 at 20:39
Add a ment  | 

1 Answer 1

Reset to default 5
window.onbeforeunload = function(e) {
    return 'some prompt text';
};

Working Example

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745113699a4611998.html

相关推荐

  • javascript - Confirm window close - Stack Overflow

    I am creating an HTML printable quiz and test maker and I would like to confirm "Are you sure you

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信