To trigger an event when the window is closed, we think of the Window object as providing two events: OnUnload and Onberforunload, because they are for document and are triggered before the document is unloaded or unloaded. But these two events are also triggered when they are refreshed, so what do we do to mask the onunload and Onberforunload events that are triggered in addition to closing the window operation? Here is what I found from the Internet, and share with you.
<script>
Window.onunload = function () {if (self.screentop>9000) alert (' This window has been closed. ')}
</script>
Or
<script>
Window.onunload = function () {if (self.screenleft>9000) alert (the window has been closed ...)}
</script>
The following is an explanation of the properties of these two windows:
Window.screentop
Gets the y-coordinate of the upper-left corner of the browser client area relative to the upper-left corner of the screen
The number behind the screentop> must be greater than the height you display in the resolution
For example, 800*600, this number is more than 600.
Window.screenleft
Gets the x-coordinate of the upper-left corner of the browser client area relative to the upper-left corner of the screen
The number behind the screenleft> must be greater than the width you display in the resolution
For example, 800*600, this number is more than 800.
Usually these two values are set to 9000
References: DHTML full reference manual http://wangwq.w4.dns2008.cn/index_web/DHTMLref/default.html