js关闭浏览器窗口及检查浏览器关闭事件

时间:2013-09-03    点击:71   
js关闭浏览器窗口

js关闭浏览器窗口,不弹出提示框。支持ie6+,火狐,谷歌等浏览器。
复制代码 代码如下:

<html>
<head />
<body>
<script type="text/javascript">
function closeWin(){
window.opener=null;
window.open('','_self','');
window.close();
}
</script>
<a onclick="closeWin()" href="#">logout</a>
</body>
</html>

火狐默认不支持js关闭浏览器窗口,可以在about:config中将dom.allow_scripts_to_close_windows改为true。

js检查浏览器关闭事件

js检查浏览器关闭或刷新事件,主动弹出提示框。支持ie6+,火狐,谷歌等浏览器。
复制代码 代码如下:

<html>
<head />
<body>
<script type="text/javascript">
window.onbeforeunload = function(){
return "quit?";
}
</script>
</body>
</html>
javascript jq 弹出层实例
jQuery选择器中含有空格的使用示例及注意事项
jQuery遍历Form示例代码
JS将秒换成时分秒实现代码
js导出table到excel同时兼容FF和IE示例
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved