Saturday, September 04, 2010

How to find browser window close or refresh using java script

Tested and works in IE, Mozilla FireFox, Safari
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>ClientScriptManager Example</title>
    <script type="text/javascript">
        window.onbeforeunload = function (evt) {
            var message = 'Are you sure you want to leave?';
            if (typeof evt == 'undefined') {
                evt = window.event;
            }
            if (evt) {
                evt.returnValue = message;
            }
            return message;
        } 
    </script>
</head>
<body>
    <form id="Form1" runat="server">
    <div>
 
    </div>
    </form>
</body>
</html>

No comments:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...