Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 946214 - Last Review: September 22, 2011 - Revision: 3.0
An HTML application that uses the "onbeforeunload" event closes unexpectedly in Internet Explorer 7 when you click "Cancel"
Consider the following scenario:
In this scenario, the HTA closes as expected when you click
OK. However, the HTA closes unexpectedly when you click
Cancel.
This issue occurs because of how the Shdocvw.dll file handles the
IOleCommandTarget::Exec method.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
This problem does not occur when you start the HTA in Microsoft Internet Explorer 6.
Steps to reproduce the problem
- Create an HTA.
- Insert the following code into the HTA:
<html>
<head>
<TITLE>TEST</TITLE>
<HTA:APPLICATION ID="TEST"
APPLICATIONNAME="TEST"
BORDER="thick"
BORDERSTYLE="normal"
CAPTION="yes"
CONTEXTMENU="no"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="yes"
SELECTION="no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
VERSION="1.0"
WINDOWSTATE="normal"/>
<script type="text/javascript">
function closeIt()
{
event.returnValue = "string value"; // Any string value here forces a dialog box to appear before the window closes.
}
</script>
</head>
<body onbeforeunload="closeIt()">
<a href="http://www.microsoft.com">Click here to navigate to www.microsoft.com </a>
</body>
</html> - In Internet Explorer 7, start the HTA.
- Close the HTA.
- Click Cancel. Notice that the window closes.
For more information about HTAs, visit the following Microsoft Developer Network (MSDN) Web site:
For more information about the
event.returnValue property, visit the following MSDN Web site:
APPLIES TO
- Windows Internet Explorer 9
- Windows Internet Explorer 7
| kbtshoot kbcode kbbug KB946214 |
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