Oct
10
Filed Under (Uncategorized) by Thejesh GN on 10-10-2007

When you try to close the main browser window using the close [ window.close(); ] method. You get the confirmation prompt

The Web page you are viewing is trying to close the window.
 Do you want to close the window?

This warnning message appears only if you are trying to close the main browser window and not the popups. To stop this use the following snippet
function closeMe(){
window.opener = "";
window.close();
}

It works because the browser checks for the value of window.opener to see if it is a child window or main window. if the value is null then it assumes the window to be main window. Now we are cheating the browser by assigning the window.opener to some random value!



Comments:
4 Comments posted on "How to close main browser window with out getting warning message"
Mads Kjaer on November 26th, 2007 at 10:06 pm

Although this may be a clever workaround, you should NEVER close, minimize or change the size of a users window(s) without him or her confirming the action first. This is an example of extremely poor usability.


zalifer on December 24th, 2007 at 2:40 am

That would be the coolest thing ever… For someone to exploit with XSS… te he he.


albert gregory on May 5th, 2008 at 1:33 am

Im trying to close a browser window down without success there must be a simple solution.


Mithun Bagchi on June 3rd, 2008 at 7:00 pm

The above script is not working in Mozilla.Could anyone please give me the mozilla compatible code to close the main browser (not popups)?

Thanks


Post a comment
Name: 
Email: 
URL: 
Comments: