Source: http://hi.baidu.com/wr5532/blog/item/b3546037ca99423c0b55a96a.html
Dialog Box with confirmation:
< Script >
If (Confirm ( " Are you sure you want to close this page? " ))
{
Self. Opener = Null ;
Self. Open ( '' , ' _ Self ' );
Self. Close ();
}
</ Script >
Close directly without prompting:
< Script >
Self. Opener = Null ;
Self. Open ( '' , ' _ Self ' );
Self. Close ();
</ Script >
Note:
TheseCodeSometimes it does not work under ff, and the system prompts "Do Not Allow scripts to close pages that are not opened by scripts". You need to modify the FF settings and
The method is as follows:
Open Firefox and enter about: config in the address bar.
Find Dom. allow_scripts_to_close_windows and change it to true.
========================================================== ==================================
Supplement:
Window. Close ();
In Chrome, there is no response, and FF is directly disabled without asking.