The first type: JS automatically closes the window regularly
<script language="javascript">
<!--
function closewin()
{
self.opener=null;
self.close();
}
functionclock()
{
i=i-1
document.title="This window will automatically close in " + i + " seconds!";
if(i>0)setTimeout("clock();",1000);
else closewin();
}
var i=10
clock();
//-->
</script>
Second type: Click the link to close the window without prompting JS
<a href="javascript:window.close()" >Close window</a>
The third type: the window does not prompt the js code to automatically close
<script language=javascript>
<!--
this.window.opener = null;
window.close();
//-->
</script>
IE6-7 JS method to close the window without prompting
Method one:
js code
function CloseWin() //This will not prompt whether to close the browser
{
window.opener=null;
//window.opener=top;
window.open("","_self");
window.close();
}
Method two:
open.html
js code
function open_complex_self() {
var obj_window = window.open('close.html', '_self');
obj_window.opener = window;
obj_window.focus();
}
close.html
js code
window.close();
Also attached:
//Normal closed with prompt
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();
}