/**
        浏览器版本信息
        * @type {Object}
        * @return {Boolean} 返回布尔值
        */
        function browser() {
            var u = navigator.userAgent.toLowerCase();
            var app = navigator.appVersion.toLowerCase();
            return {
                txt: u, // 浏览器版本信息
                version: (u.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1], // 版本号
                msie: /msie/.test(u) && !/opera/.test(u), // IE内核
                mozilla: /mozilla/.test(u) && !/(compatible|webkit)/.test(u), // 火狐浏览器
                safari: /safari/.test(u) && !/chrome/.test(u), //是否为safair
                chrome: /chrome/.test(u), //是否为chrome
                opera: /opera/.test(u), //是否为oprea
                presto: u.indexOf('presto/') > -1, //opera内核
                webKit: u.indexOf('applewebkit/') > -1, //苹果、谷歌内核
                gecko: u.indexOf('gecko/') > -1 && u.indexOf('khtml') == -1, //火狐内核
                mobile: !!u.match(/applewebkit.*mobile.*/), //是否为移动终端
                ios: !!u.match(/\(i[^;]+;( u;)? cpu.+mac os x/), //ios终端
                android: u.indexOf('android') > -1, //android终端
                iPhone: u.indexOf('iphone') > -1, //是否为iPhone
                iPad: u.indexOf('ipad') > -1, //是否iPad
                webApp: !!u.match(/applewebkit.*mobile.*/) && u.indexOf('safari/') == -1 //是否web应该程序,没有头部与底部
            };
        }
        var timeout;
        function open_appstore() {
            var b=browser();
            if(b.ios||b.iPhone||b.iPad){
                window.location="itms-apps://itunes.apple.com/cn/app/qq-2011/id444934666?mt=8";
            }else if(b.android){
                //
            }
        }
        function try_to_open_app() {
            var b=browser();
            if(b.ios||b.iPhone||b.iPad){
                window.location="mqq:open";
            }else if(b.android){
                //
            }
            timeout = setTimeout('open_appstore()', 30);
        }
        try_to_open_app();


const log = console.log;

window.onhashchange = locationHashChanged;

function locationHashChanged(e) {
    log(`location.hash`, location.hash);
    log(`e.oldURL, e.newURL`, e.oldURL, e.newURL);
    // if (location.hash === "#pageX" ) {
    //     pageX();
    // }
},
  
const autoOpenApp = () => {
    try {
        log(`try open installed app!`);
        window.location = "mqq:open";
    } catch (err) {
        log(`open app uninstalled!`, err);
        // window.location = "mqq:open";
    }
    // window.location.addEventListener(`reload`, (e) => {
    //     log(`window.location reload`, e);
    // });
    setTimeout(() => {
        let ua = navigator.userAgent.toLowerCase();
        let env = ua.includes(`mobile`) ? true : false;
        if (env) {
            log(`app evn`, env);
            window.location="itms-apps://itunes.apple.com/cn/app/qq-2011/id444934666?mt=8";
        } else {
            window.location="http://itunes.apple.com/cn/app/qq-2011/id444934666?mt=8";
            log(`browser evn`, env);
        }
    }, 1000);
};

document.addEventListener(`DOMContentLoaded`, () => {
    let alink = document.querySelector(`[data-link="app"]`);
    if(alink) {
        alink.addEventListener(`click`, (e) => {
            e.preventDefault;
            autoOpenApp();
        });
    }
});




HTML5 App Download Page (H5 App 下载落地页) All In One

demos

H5

HTML5 App Download Page (H5 App 下载落地页) All In One

PC

HTML5 App Download Page (H5 App 下载落地页) All In One

Android Deep Link & iOS Universal Link & URL Scheme

https://www.cnblogs.com/xgqfrms/tag/Deep Link/

refs

http://mobile.sptcc.com/mobiledownload/download_pc.html

http://mobile.sptcc.com/event/?from=timeline&isappinstalled=1



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 ????️,侵权必究⚠️!


相关文章:

  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-11-29
  • 2021-10-26
猜你喜欢
  • 2022-12-23
  • 2022-01-14
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
相关资源
相似解决方案