小程序内嵌网页,安卓可以下载app,ios不行,可以解决吗?朋友圈或者微信好友分享的网页可以实现ios跳转applestore下载
<script type=“text/javascript”>
var browser = {
versions: function() {
var u = navigator.userAgent, app = navigator.appVersion;
return {
trident: u.indexOf(‘Trident’) > -1,
presto: u.indexOf(‘Presto’) > -1,
webKit: u.indexOf(‘AppleWebKit’) > -1,
gecko: u.indexOf(‘Gecko’) > -1 && u.indexOf(‘KHTML’) == -1,
mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/),
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
android: u.indexOf(‘Android’) > -1 || u.indexOf(‘Linux’) > -1,
iPhone: u.indexOf(‘iPhone’) > -1 || u.indexOf(‘Mac’) > -1,
iPad: u.indexOf(‘iPad’) > -1,
webApp: u.indexOf(‘Safari’) == -1
};
}(),
language: (navigator.browserLanguage || navigator.language).toLowerCase()
}
var isWeixin = is_weixin();
if (browser.versions.ios || browser.versions.iPhone || browser.versions.iPad) {
window.location=“https://itunes.apple.com/cn/app/id1353241772?mt=8”;
}
else if (browser.versions.android) {
if (isWeixin) {
document.getElementById(“content”).style.display=“block”;
}
document.getElementById(“clickgoweixin”).style.display=“block”;
window.location=“https://www.xxx.com/xxx-latest.apk”;
}
function is_weixin() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == “micromessenger”) {
return true;
} else {
return false;
}
}
var gowei = document.getElementById(“clickgoweixin”);
gowei.onclick=function clickgoweixin() {
wx.miniProgram.navigateTo({url: ‘/pages/index/index’})
}
</script>