How to close IE7 without prompting using javascript

Hi all, javascript is indispensable to any web-app. You always use window.close() to close an window. But there is a problem when your code are running in IE7. It will prompt a confirm dialog and upset you developer .
Today, I show a way to adapt your existing code to work well in IE7 without changing to much.
That is, you override the window.close() method:

var oldClose = window.close;

window.close = function()

{

window.open(”, ‘_self’);
window.opener = null;

oldClose);

}

Now, the invocation to window.close() works well on all IE.

Hope this help!
Nguyen Minh Dung

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: