PDA

View Full Version : Supressing Window.Close Message Box


Rosane
08-12-2002, 10:16 PM
Is there a way to suppress The automatic message box that pops up in IE when a window is closed ('The Web Page you are viewing is trying to close The widow. Do you want to close this window')?

<body onload="window.opener.close">

Please, Help!!

sane_rj

Quiet Storm
08-12-2002, 11:34 PM
There is a way, but every time I post the code, someone here gets all upset at me and starts ranting on about how it's a "Security Flaw" or a "Bug" that could be used in a harmful or malicious way. Telling me that it's an annoying design tactic that shouldn't be used and that I shouldn't be telling people about this "trick" because it may be unsafe.

But that's CENSORSHIP for ya! :mad:





So, here it is. :D

<BODY>

<A HREF="#" onClick="closes.Click();">CLOSE</A>

<object id="closes" type="application/x-oleobject"
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close">
</object>

</BODY>


For a more advanced feature, like opening a new window then automatically closing the first:


<head>

<script type="text/javascript">
function DoIt() {
window.open('mywin.htm','myWin','height=400,width=400');
window.focus();
closes.Click(); }
</script>

</head>
<body onload="DoIt()"
<object id="closes" type="application/x-oleobject"
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close">
</object>
</body>

brothercake
08-13-2002, 04:40 AM
I'm not going to rant, but it is a security flaw that that works outside active-x/hta environments, and it is extremely irritating when a site closes my main window.

Use it if you want ... but you'll lose traffic from it

jkd
08-13-2002, 05:00 AM
I seem to remember:

window.opener = top;
window.close();

works fine for killing the alert. (kind of a bug found in most browsers)