Script error closing window in embedded IE7 control (not standalone IE7, nor prior versions of IE)  
Author Message
M4lc





PostPosted: Internet Explorer Web Development, Script error closing window in embedded IE7 control (not standalone IE7, nor prior versions of IE) Top

I also have a situation where a script generates an error in the browser embedded within our app, but not in stand-alone IE7 where it is ok. It works fine in the embedded situation on systems with older versions of IE.

This involves a script that is trying to close a window that has already been closed by the user. No errors occur except in the case of the embedded browser control on IE7 systems, in which case a "permission denied" exception is being thrown.

This is old C++ code has worked since IE5 days, and hasn't changed. Surely there must be something I can configure in our C++ code to revert to the usual behaviour. Can anybody help - it would be prohibitively expensive to fix all our JavaScript code locations to check whether the window has already closed, but I also fear other things might be affected too.

Test page follows:

<html>
<head>
<title>Script Error</title>

<script language="javascript" type="text/javascript">
var windowsToClose = new Array(); //for holding references to windows that need to be closed

function closeAllWindows()
{
while (windowsToClose.length > 0)
{
var WinObj = windowsToClose.pop();
try
{
// Permission denied scripting error on following line when invoke in
// embedded web browser on system with IE7
WinObj.close();
}
catch (excp)
{
alert("Caught exception: " + excp.message);
throw excp;
}
}
alert("All Windows Closed");
}

function openWindow()
{
windowsToClose.push(window.open(" http://www.hide-link.com/ "));
}
</script>

</head>
<body>
<h3>
Explanation:</h3>
<p>
The core problem with the window closing script in this page is that it relies on
a variable to track how many winows have been opened. When a point in the code calls
on the script to close a window, it does not look to see if the window is still
open, instead it blindly attempts to close the window regardless of whether or not
the window is indeed open.</p>
<p>
Under Internet Explorer 6 no error was presented to the user when the code attempted
to close a window that was not present. Under Internet Explorer 7 each time a window
that is not open has a &quot;close&quot; fuction fun on it, there will be a IE script
error.</p>
<p>
&nbsp;</p>
<h3>
To Use:</h3>
<p>
To simulate the error, do the following with IE7 installed:</p>
<ol>
<li><a href=openWindow();">Click here to open a pop-up window.</a>
<li>Close it manually.</li>
<li><a href=closeAllWindows();">Click here to once again close all open
windows.</a></li>
<li>You should have had a script error occur when you performed the previous step. If
you didn't see a script error, did you see the dialog saying "All Windows Closed" .
If you didn't see either message, there was a script error, but IE didn't display
a message</li>
</ol>
</body>
</html>


Internet Explorer Development1  
 
 
M4lc





PostPosted: Internet Explorer Web Development, Script error closing window in embedded IE7 control (not standalone IE7, nor prior versions of IE) Top

Bump