Sign in
in
   
"It is the mark of an educated mind to be able to entertain a thought without accepting it."  -Aristotle

About Me

I am a co-founder of Notches, an early stage startup currently based in NYC. We are building a free, open reviews network that anyone can participate in and anyone can build on top of. You can find out more on our official blog.

Read more about my background.

Connect with me on...

Recent Readers

Flickr Photos

 

Warning:

This article is more than 45 days old. Given the speed at which the technology world moves, this post is probably somewhat out of date. Please keep this in mind when reading the post. If this is a tutorial, please check whether you are using the same versions mentioned in the article.

HOWTO: Closing an Internet Explorer window without the security dialog

This question had come up the other day and thought others might find this useful.

When you call the window.close() method, Internet Explorer checks whether the opener value is the same as the calling window. If it's not, then the user is prompted with a security dialog asking whether they really want to close the window.

You can work around this by setting the property yourself and thus tricking IE into closing without a prompt.


function closeThisWindow()
{
    window.opener = window;
    window.close();
}

(Not tested in Firefox)

Only published comments... Feb 01 2005, 02:21 PM by Tim

View related posts

   

TrackBack said:

February 1, 2005 2:21 PM
 

Ron green said:

I just used this. It makes closing the window so much cleaner.
Thank you very much.
February 9, 2005 7:11 PM
 

Guillermo de la Maza said:

Tried this but somehow I cannot make it work on IE6 SP1 on XP pro SP1. I just pasted the above code on the child html.

What am I doing wrong?
March 7, 2005 12:17 AM
 

Tim Marman said:

Are you actually calling the function?

If you are just calling window.close, you would want to remove the function declaration...

<script>
window.opener = window;
</script>
March 7, 2005 5:48 AM