JavaScript Reference/Event Handlers Reference/onBeforeUnload

Материал из Web эксперт
Перейти к: навигация, поиск

"onBeforeUnload" Example

    
<head>
<script language="JavaScript">
    function function1() { 
        self.close() 
    }
    function function2() {
        window.open("http://www.wbex.ru/", "", "width=300, height=200, left=200, noresize, top=200")
    } 
</script>
</head>
<body onbeforeunload="function2()">
    <input type="button" value="Unload the document" onclick="function1()">
</body>
</html>



"onBeforeUnload" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<body>                          <frameset>                    |
|                |window                                                        |
+----------------+--------------------------------------------------------------+



"onBeforeUnload" Properties

+----------------+--------------------------------------------------------------+
| Properties     |altKey                          altLeft                       |
|                |clientX                         clientY                       |
|                |ctrlKey                         ctrlLeft                      |
|                |returnValue                     shiftKey                      |
|                |shiftLeft                       type                          |
+----------------+--------------------------------------------------------------+



"onBeforeUnload" Syntax and Note

Note:
    
This event fires before the document is unloaded. 
The document is unloaded when the user 
     1)navigates to a different URL   or 
     2)attempts to close the browser window.