【问题标题】:Detect browser close in jquery/javascript for cross browser [duplicate]检测跨浏览器的jquery / javascript中的浏览器关闭[重复]
【发布时间】:2013-02-18 10:42:27
【问题描述】:

window.onbeforeunload / window.onunload 在 chrome 中无法检测浏览器关闭事件。需要帮助!

【问题讨论】:

    标签: javascript jquery asp.net


    【解决方案1】:

    检查这个 http://help.dottoro.com/ljhtbtum.php

    示例 http://help.dottoro.com/external/examples/ljhtbtum/onbeforeunload_1.htm

    代码

    <head>
        <script type="text/javascript">
            function OnBeforeUnLoad () {
                return "All data that you have entered will be lost!";
            }
        </script>
    </head>
    <body onbeforeunload="return OnBeforeUnLoad ()">
        <b>Close this window or press F5 to reload the page.</b>
        <br /><br />
        <form>
            User name: <input type="text" name="username" />
            <br />
            City: <input type="text" name="city" />
        </form>
    </body>
    

    【讨论】:

      猜你喜欢
      • 2014-02-21
      • 2011-09-26
      • 2015-05-16
      • 2013-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-24
      相关资源
      最近更新 更多