首页 > 移动平台 > 详细

ios协议调起app

时间:2014-12-24 13:16:45      阅读:303      评论:0      收藏:0      [点我收藏+]
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);
}

  

ios协议调起app

原文:http://www.cnblogs.com/xiaohui108/p/4182107.html

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