js判断手机是否安装了某一款app,有则打开,没有去下载
function openApp() {if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {letloadDateTime = new Date();window.setTimeout(function() {let timeOutDateTime = new Date();if (timeOutDateTime
·
function openApp() {
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
letloadDateTime = new Date();
window.setTimeout(function() {
let timeOutDateTime = new Date();
if (timeOutDateTime - loadDateTime < 5000) {
// 跳转至app下载页 以微信为例
window.location = "http://sj.qq.com/myapp/detail.htm?apkName=com.tencent.mm";
} else {
window.close();
}
}, 25);
// 打开本地的app 以微信为例
window.location = "wexin://";
} else if (navigator.userAgent.match(/android/i)) {
let loadDateTime = new Date();
window.setTimeout(function() {
let timeOutDateTime = new Date();
if (timeOutDateTime - loadDateTime < 5000) {
// 跳转至app下载页
window.location = "http://sj.qq.com/myapp/detail.htm?apkName=com.tencent.mm";
} else {
window.close();
}
}, 25);
// 打开本地的app
window.location = "wexin://";
}
}
简写为
function openApp() {
let loadDateTime = new Date();
window.setTimeout(function() {
let timeOutDateTime = new Date();
if (timeOutDateTime - loadDateTime < 5000) {
// 跳转至app下载页 以微信为例
window.location = "http://sj.qq.com/myapp/detail.htm?apkName=com.tencent.mm";
} else {
window.close();
}
}, 25);
// 打开本地的app 以微信为例
window.location = "wexin://";
}
更多推荐
已为社区贡献1条内容
所有评论(0)