-2

window.onbeforeunload / window.onunload not working in chrome for detecting browser close event. Need some help!

1 Answers1

2

Check this http://help.dottoro.com/ljhtbtum.php

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

code

<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>
Nipun Ambastha
  • 2,553
  • 1
  • 16
  • 26