JS closed Windows and JS closed several methods of page summary
- 2020-03-30 00:54:26
- OfStack
The first: JS timing automatically close the window
< Script language = "javascript" >
< ! --
The function closewin ()
{
The self. The opener = null;
The self. The close ();
}
The function clock ()
{
I = I - 1
Document.title =" this window will close automatically after "+ I +" seconds!" ;
If (i> 0) setTimeout (" clock ();" , 1000);
The else closewin ();
}
Var I = 10
Clock ();
/ / - >
< / script>
Second: click on the link to close the window without prompting JS
< A href = "javascript: window. Close ()" > Close the window < / a>
Third: the window does not prompt the automatic closure of js code
< Script language = javascript>
< ! -
This. Window. Opener = null;
Window. The close ();
/ / - >
< / script>
Ie6-7 JS method to close Windows without prompting
Method one:
Js code
Function CloseWin() // this does not prompt whether to close the browser
{
Window. The opener = null;
/ / the window. The opener = top;
Window. The open (" ", "love");
Window. The close ();
}
Method 2:
Open the HTML
Js code
The function open_complex_self () {
Var obj_window = window.open('close.html', '_self');
Obj_window. Opener = window;
Obj_window. Focus ();
}
Close the HTML
Js code
Window. The close ();
Attach:
// normal tape prompt closed
The function closeie () {
Window. The close ();
}
// close IE6 without prompting
The function closeie6 () {
Window. The opener = null;
Window. The close ();
}
// close IE7 without prompting
The function closeie7 () {
Window. The open (', '_top');
Window. The top. The close ();
}