JS close window or JS close page of several code sharing
- 2020-03-26 21:37:40
- OfStack
The first: JS timing automatically close the window
<script language="javascript">
<!--
function closewin(){
self.opener=null;
self.close();}
function clock(){i=i-1
document.title=" This window will be in "+i+" Automatic shutdown after seconds !";
if(i>0)setTimeout("clock();",1000);
else closewin();}
var i=10
clock();
//-->
</script>
Second: click on the link to close the window without prompting JS
<a href="javascript:self.close()" > Close the window </a>
The third kind: the window does not prompt to close automatically js code
<script language=javascript>
<!--
this.window.opener = null;
window.close();
//-->
</script>
Third: PHP code after the submission window prompt message and automatically close the window js code
document.write "<script language=javascript>alert(' Your message was sent successfully, we will timely contact you after we see it! ');opener=null;window.close();</script>"
Automatically return the code of the previous page:
document.write("<script language=""JavaScript"">alert("" Your message was sent successfully, we will timely contact you after we see it! "");history.go(-1);</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 & NBSP;
{
window.opener=null;
//window.opener=top;
window.open("","_self");
window.close();
}
Method 2:
Open the HTML
js code
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.close();
Attach:
//Normal tape prompt closed
function closeie(){
window.close();
}
//Close IE6 without prompting
function closeie6(){
window.opener=null;
window.close();
}
//Close IE7 without prompting
function closeie7(){
window.open('','_top');
window.top.close();
}