js关闭当前页面完整版

              var userAgent = window.navigator.userAgent;
              var ua = userAgent.toLowerCase();
                  if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                    // 微信浏览器
                    window.WeixinJSBridge.call('closeWindow');
                  } else {
                    // 非微信浏览器
                    if (userAgent.indexOf("MSIE") > 0) {
                      if (userAgent.indexOf("MSIE 6.0") > 0) {
                        window.opener = null;
                        window.close();
                      } else {
                        window.open("", "_top");
                        window.top.close();
                      }
                    } else if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") != -1) {
                      window.location.href = "about:blank "; //火狐默认状态非window.open的页面window.close是无效的
                    } else {
                      window.opener = null;
                      window.open("about:blank", "_self");
                      window.close();
                    }
                  }

你可能感兴趣的:(js关闭当前页面完整版)