Triggers an event when a window is closed (triggered when masking refreshes)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.