zoukankan      html  css  js  c++  java
  • js 关闭浏览器

    使用js关闭浏览器,ios下的uc、360、qq有问题

        ```
        var u = navigator.userAgent
        var isiOS = !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        var isSafari = u.toLowerCase().indexOf('safari') != -1
        if(isiOS) {
            // ios的safari支持window.close,uc、360、qq浏览器不支持
            if(isSafari) {
                window.opener = null;
                window.open("","_self").close()
            }
            return
        }
        if (navigator.userAgent.indexOf("MSIE") > 0) { //close IE  
            if (u.indexOf("MSIE 6.0") > 0) {
                window.opener = null;
                window.close();
            } else {
                window.open('', '_top');
                window.top.close();
            }
        } else if (u.indexOf("Firefox") > 0) { //close firefox  
            window.location.href = 'about:blank';
        } else if (u.toLowerCase().indexOf("ucbrowser") > 0) {
            window.location.href = '';
            setTimeout(()=>{
                window.location.href = 'about:blank';
            },0)
        } else { //close chrome;It is effective when it is only one.  
            window.opener = null;
            window.open("","_self").close()
            window.location.href = 'about:blank';
        }
        ```
  • 相关阅读:
    1014. 福尔摩斯的约会
    1009. 说反话
    1002. 写出这个数
    1031. 查验身份证
    1021. 个位数统计
    1006. 换个格式输出整数
    1058. A+B in Hogwarts
    1027. Colors in Mars
    1019. General Palindromic Number
    Windows 新装进阶操作指南
  • 原文地址:https://www.cnblogs.com/ethy/p/8028552.html
Copyright © 2011-2022 走看看