zoukankan      html  css  js  c++  java
  • H5 关闭浏览器 监听 窗口关闭 或刷新窗口

    H5 关闭浏览器

    function win_close () {
      // 判断是否支持WeixinJSBridge 微信环境
      if (typeof WeixinJSBridge !== 'undefined') {
        WeixinJSBridge.call('closeWindow')// 微信自带的关闭窗口WeixinJSBridge.call("closeWindow")
      } else {
        // H5 环境
        if (navigator.userAgent.indexOf('MSIE') > 0) {
          if (navigator.userAgent.indexOf('MSIE 6.0') > 0) {
            window.opener = null
            window.close()
          } else {
            window.open('', '_top')
            window.top.close()
          }
        } else if (navigator.userAgent.indexOf('Firefox') > 0) {
          window.location.href = 'about:blank '
        } else {
          window.opener = null
          window.open('', '_self', '')
          window.close()
        }
      }
    }

    监听 窗口关闭 或刷新窗口

    var ua = navigator.userAgent.toLowerCase()
    let isAndroid = ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1
        if (isAndroid) {
        // 安卓   window.onbeforeunload
    = function (e) { e = e || window.event // 处理函数 return '' } } else {
        // ios window.addEventListener(
    'pagehide', myUnloadHandler, false) function myUnloadHandler () { // 处理函数 } }
  • 相关阅读:
    树型表的设计 上海
    FTP通讯封装 上海
    线程淡写 上海
    TCP通讯故障 上海
    设计模式引导 上海
    初试Delegate 上海
    c# 扫描端口 上海
    攻读计算机研究生的看法(转载) 上海
    挖掘表字段中的汉字 上海
    新生活运动 上海
  • 原文地址:https://www.cnblogs.com/wukongz/p/13570346.html
Copyright © 2011-2022 走看看