pangblog

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>

 

分类:

技术点:

相关文章:

  • 2021-12-06
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
相关资源
相似解决方案