How can I close a browser window without receiving the "Do you want to close this window" prompt"?
The prompt occurs when I use the window.close(); command.
Derek
How can I close a browser window without receiving the "Do you want to close this window" prompt"?
The prompt occurs when I use the window.close(); command.
Derek
The best solution I have found is:
this.focus(); self.opener=this; self.close();
From here:
<a href="javascript:window.opener='x';window.close();">Close</a>
You need to set window.opener to something, otherswise it complains.
The browser is complaining because you're using JavaScript to close a window that wasn't opened with JavaScript, i.e. window.open('foo.html');
.
My friend.. there is a way but Hack does not begin to describe it. You have to basically exploit a bug in IE 6 & 7.
Works every time!
Instead of calling window.close() redirect to another page.
Opening Page:
alert("No whammies!");
window.open("closer.htm", '_self');
Redirect to another page. This fools IE into letting you close the browser on this page.
Closing Page:
<script type="text/javascript">
window.close();
Awesome huh?!
-Nick