Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 934367 - Last Review: July 29, 2009 - Revision: 2.0
How to determine when a browser window is closing in Internet Explorer 7
This article describes how to determine when a browser window is closing in Windows Internet Explorer 7. This behavior differs from the behavior that occurs when a Web page is refreshed. This behavior also differs from the behavior that occurs when a URL is visited from another Web page.
Window properties such as the
window.screenTop property and the
window.screenLeft property do not work in Windows Internet Explorer 7. This behavior differs from the behavior of Microsoft Internet Explorer 6.
For example, in Internet Explorer 7, the following code does not cause a message to appear when you close a browser window:
<html>
<script>
function closeHandler() {
if (window.screenTop > 9000 && window.screenLeft > 9000) {
alert("The window will be closed");
}
}
window.onunload = closeHandler;
</script>
<body>
Test page
</body>
</html>
To determine when the browser window is closing, use any of the following methods:
- Use a modal dialog box as the main window.
- Use a parent frameset. Use the onunload event of the parent frameset to determine when the browser window closes.
APPLIES TO
- Windows Internet Explorer 7
| kbinfo kbwebbrowser kbtshoot KB934367 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate