JavaScript无提示关闭当前页面窗口,兼容IE/Firefox/Chrome (Close the current page window without confirm by JavaScript, support all browsers)

来源:互联网 发布:微博刷赞软件手机版 编辑:程序博客网 时间:2024/05/28 19:25
 

Test by IE7/ Firefox 3.0/ Google Chrome

 


<script>

var browserName=navigator.appName; 
if (browserName=="Netscape")

    
function closeme() 
    { 
        window.open(
'','_parent',''); 
        window.close();
    } 

else 

    
if (browserName=="Microsoft Internet Explorer"
    { 
        
function closynoshowsme() 
        { 
            window.opener 
= "whocares"
            window.close(); 
        } 
    } 


</script>

<input type="button" value="close me 3" onclick="closeme();"/>

 

Note:

If you are using Firefox, please make sure your settings:

1.type "about:config" into your address bar, and enter.

2.find the key named "dom.allow_scripts_to_close_windows" make sure the value is True

OK, enjoy the code