<script> function window_close(){ if (navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Chrome") !=-1) { window.location.href="/self_close.htm"; window.close(); } else { window.opener = null; window.open("/self_close.htm", "_self"); window.close(); } } </script>
self_close.htm
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>关闭</title> </head> <body> <script type="text/javascript" language="javascript">self.close();</script> <h1>关不掉页面?</h1> <hr> <p>如果您用的Firefox(火狐)浏览器,默认不允许执行非弹出式窗口的关闭脚本。</p> <p>可以通过更改Firefox的设置来实现:</p> <p>在地址栏输入:about:config</p> <p>搜索:dom.allow_scripts_to_close_windows</p> <p>(双击)将值 false 改为 true;</p> <p> </p> </body> </html>