点击手机按钮存在APP则唤醒否则打开应用商店
因为js无法检测到手机上是否有当前软件,延时器判断当前页面是否关闭来进行判断const openApp = () => {var u = navigator.userAgent;var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //gvar isIOS = !!u.match(/\(i[^;
js无法检测到手机上是否有安装有当前软件,延时判断当前页面是否关闭来进行判断
const openApp = () => {
var u = navigator.userAgent;
var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //g
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isAndroid) {
window.location.href = "";
setTimeout(function () {
let hidden =
window.document.hidden ||
window.document.mozHidden ||
window.document.msHidden ||
window.document.webkitHidden;
if (typeof hidden == "undefined" || hidden == false) {
window.location.href =
"";
}
}, 1500);
}
if (isIOS) {
//iosapp
window.location.href = "";
setTimeout(function () {
let hidden =
window.document.hidden ||
window.document.mozHidden ||
window.document.msHidden ||
window.document.webkitHidden;
if (typeof hidden == "undefined" || hidden == false) {
window.location.href =
"";
}
}, 1500);
return false;
}
};
更多推荐
所有评论(0)