zoukankan      html  css  js  c++  java
  • js 打开app应用,如果没有安装就去下载

    废话不多说,直接上代码

    var APPCommon = {
        iphoneSchema: 'XingboTV://',
        iphoneDownUrl: 'https://itunes.apple.com/cn/app/xing-botv-mei-nu-shuai-ge3d/id1098066581?l=en&mt=8',
        androidSchema: 'scheme://com.xingbo/',
        androidDownUrl: 'http://webrs.xingbo.tv/app/XingboLive-release.apk',
        openApp: function(){
            var this_  =  this;
            //微信
            if(this_.isWeixin()){
                $(".weixin-tip").css("height",$(window).height());
                $(".weixin-tip").show();
                $('.weixin-tip').on('touchstart', function () {
                    $(".weixin-tip").hide();
                });
    
            }else{//非微信浏览器
                if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
                    var loadDateTime = new Date();
                    window.setTimeout(function() {
                        var timeOutDateTime = new Date();
                        if (timeOutDateTime - loadDateTime < 5000) {
                            window.location = this_.iphoneDownUrl;//ios下载地址
                        } else {
                            window.close();
                        }
                    },25);
                    window.location = this.iphoneSchema;
                }else if (navigator.userAgent.match(/android/i)) {
                    try {
                        window.location = this_.androidSchema;
                        setTimeout(function(){
                            window.location=this_.androidDownUrl; //android下载地址
    
                        },500);
                    } catch(e) {}
                }
            }
        },
        isWeixin: function(){ //判断是否是微信
            var ua = navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == "micromessenger") {
                return true;
            } else {
                return false;
            }
        }
    
    };
    

      代码中包括了了iphone,android的,还有微信的判断

  • 相关阅读:
    HDU 1301 Jungle Roads (最小生成树)
    POJ 1733 Parity game (并查集)
    HDU 3038 How Many Answers Are Wrong (并查集)
    CentOS用yum安装搭建LAMP
    Linux下php安装Redis扩展
    PHPExcel用法
    利用phpmailer类邮件发送
    Vim编辑器配置
    vhost文件设置
    ThinkPHP验证码类
  • 原文地址:https://www.cnblogs.com/myzy/p/5852055.html
Copyright © 2011-2022 走看看