首页 > Web开发 > 详细

js实现关闭浏览器

时间:2020-05-27 11:34:43      阅读:40      评论:0      收藏:0      [点我收藏+]

兼容所有浏览器网页关闭方法

  

 1 <button  id="exitSystem" onclick="CloseWebPage()">关闭</button>
 2         <script>
 3             function CloseWebPage() {
 4                 if (navigator.userAgent.indexOf("MSIE") > 0) {
 5                     if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
 6                         window.opener = null; window.close();
 7                     }
 8                     else {
 9                         window.open(‘‘, _top); window.top.close();
10                     }
11                 }
12                 else if (navigator.userAgent.indexOf("Firefox") > 0) {
13                     window.location.href = about:blank ; //火狐默认状态非window.open的页面window.close是无效的
14                     //window.history.go(-2);
15                 }
16                 else {
17                     window.opener = null;
18                     window.open(‘‘, _self, ‘‘);
19                     window.close();
20                 }
21             }
22         </script>

 

 

第二种方法,也可以针对谷歌浏览器的

1 <button style="margin-left: 500px" onclick="CloseWebPage()">退出</button>
2 <script>
3     function CloseWebPage() {
4         open(location, _self).close();
5     }
6 </script>

 

 

以上两种方法,亲测有效!!!!

js实现关闭浏览器

原文:https://www.cnblogs.com/winton-nfs/p/12971254.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!