網頁 調用 原生應用

能夠從頁面挑戰到APP,也能夠從APP跳回頁面啦
 

從網頁上是沒辦法檢測手機是否安裝了某個應用,可是有一個小技巧:若是能打開本地應用的話,就會跳出頁面打開(從而關掉定時器),不會轉向下載頁,而不能打開本地應用,就會轉向下載頁面jquery

 
知乎代碼:
          $("#js-open-in-app").on("click", function() {
                var b = $('meta[name="apple-itunes-app"]').attr("content");
                if (b) {
                    b = (new jj(b.replace(/,\s*/, "&"))).get("app-argument") || "";
                    -1 === b.indexOf("zhihu://") && (b = "zhihu://" + b);
                    if (/Android/.test(navigator.userAgent)) {
                        var c = b.replace(/^zhihu/, "intent") + "/#Intent;scheme=zhihu;package=com.zhihu.android;end", d = navigator.userAgent.match(/Chrome\/(\d+)/);
                        if (25 <= (d && d[1]))
                            window.location = c;
                        else {
                            c = document.createElement("iframe");
                            c.hidden = j;
                            c.src = b;
                            document.body.appendChild(c);
                            var e = za();
                            window.setTimeout(function() {
                                600 > za() - e && (window.location = "http://api.zhihu.com/client/download/apk")
                            }, 400)
                        }
                    } else {
                        var g = m;
                        window.location = b;
                        window.setTimeout(function() {
                            g = j;
                            window.location = "http://itunes.apple.com/cn/app/id432274380"
                        }, 250);
                        window.setTimeout(function() {
                            g && window.location.reload()
                        }, 500)
                    }
                    W("app-promotion", "click_zhihu_ios_open_dl_link", "header_not_logged_in")
                }
            })
 
 
插件
相關文章
相關標籤/搜索