Showing posts with label closing window without prompting. Show all posts
Showing posts with label closing window without prompting. Show all posts

Thursday, October 16, 2008

Using window.close() without prompt in IE7

Hi Readers,

If you have tried using javascript window.close() method in IE7, you will notice that it is always prompting “The Webpage you are viewing is trying to close the window. Do you want to close this window?”.

To let this prompt not to appear, just do the codes below.

script language="javascript"
function CloseWindow()
{
window.open(”,’_self’,”);
window.close();
}
/script

Or if you want to close the Parent window without prompting, just use:
window.opener.open(”,’_self’,”);
window.opener.close();

The code in bold is used to open a window which lets the browser thinks that the current window is opened using javascript window.open(), so when the close() method is executed it will close it without the message being prompted.


Best Regards,
Shaper Jabneel