Click to See Complete Forum and Search --> : closing a window


stewie
01-14-2003, 10:30 AM
Does anyone know how to close a window without IE telling you that the page is trying to close itself and you having to click yes?

the goal is to load a page of a certain size with no control/toolbars from the outset. i was trying it by having a page open the new window like i want it with onLoad="window.open(blah blah)" then closing itself using self.close(). it causes a prompt that i dont want. if im doing this the hard way another solution would be appreciated too!!

much thanks

Dan Drillich
01-14-2003, 11:02 AM
Based on http://hotwired.lycos.com/webmonkey/98/03/index3a_page8.html# please try -



<html><head><title>Getting and using a window reference</title>
<script language="JavaScript">
<!-- hide me

// open a new window and get a reference to it
var new_window = window.open("http://www.iwon.com","html_name","width=200,height=200");


// show me -->
</script>
</head>
<body>

<h1>A new window has been opened and moved to the background.</h1>
<a href="#" onMouseOver="new_window.focus();">Bring it forward</a><br>
<a href="#" onMouseOver="new_window.close();">Close it</a><br>


</body>
</html>


Cheers,
Dan

gil davis
01-14-2003, 11:03 AM
That message is a security feature. It indicates that you are trying to close a window that was not opened using the javascript "window.open()" method. The message cannot be avoided in that case. Sorry.

stewie
01-14-2003, 02:03 PM
thanks for the tips so far. super helpful