zoukankan      html  css  js  c++  java
  • ios协议调起app

    function openIos(url, callback) {
        if (!url) {
            return;
        }
        var node = document.createElement('iframe');
        node.style.display = 'none';
        var body = document.body;
        var timer;
        var clear = function(evt, isTimeout) {
           (typeof callback==='function') &&  callback(isTimeout);
            window.removeEventListener('pagehide', hide, true);
            window.removeEventListener('pageshow', hide, true);
            if (!node) {
                return;
            }
    
            node.onload = null;
            body.removeChild(node);
            node = null;
    
        };
        var hide = function(e){
            clearTimeout(timer);
            clear(e, false);
        };
        window.addEventListener('pagehide', hide, true);
        window.addEventListener('pageshow', hide, true);
        node.onload = clear;
        node.src = url;
        body.appendChild(node);
        var now = +new Date();
        //如果事件失败,则1秒设置为空
        timer = setTimeout(function(){
            timer = setTimeout(function(){
              var newTime = +new Date();
              if(now-newTime>1300){
                clear(null, false);
              }else{
                clear(null, true);
              }
    
            }, 1200);
        }, 60);
    }
    

      

  • 相关阅读:
    Redis单机操作
    Scala
    RDD算子
    Python学习之旅(七)
    python学习之旅(六)
    python学习之旅(五)
    python学习之旅(四)
    python学习之旅(二)
    python学习之旅(三)
    Python学习之旅(一)
  • 原文地址:https://www.cnblogs.com/xiaohui108/p/4182107.html
Copyright © 2011-2022 走看看