in the process of testing H5 to wake up app, when does not install app, the [Taobao] [JD.com] of under safari will appear a pop-up prompt of "invalid URL" (as shown in the figure).
but Zhihu will not appear this prompt, but will jump directly to the download page. How can Zhihu avoid it? Please answer!
attach the core code written with reference to other articles:
// app
ue.checkApp = function () {
var _clickTime = +(new Date());
function check(elsTime) {
if ( elsTime > 3000 || document.hidden || document.webkitHidden) {
// cb(1);
console.log("app")
} else {
location.href = downloadUrl
}
}
//20ms3000ms
var _count = 0, intHandle;
intHandle = setInterval(function(){
_countPP;
var elsTime = +(new Date()) - _clickTime;
if (_count>=100 || elsTime > 3000 ) {
clearInterval(intHandle);
check(elsTime);
}
}, 20);
};
// href
$btnOpenApp.attr("href", scheme)
//
$btnOpenApp.on("click", function() {
//
if (browser.isWeChat) {
$(".pop-openbrowser").show();
} else {
ue.checkApp();
}
});