ios和安卓共用一个二维码,实现扫码跳转链接
直接上代码了 也是参考了网上的demo,直接小修改了一下。临时接了一个任务,直接套过来了。因为安卓微信的内置的浏览器和手机自带的不一样,在ios上面没有问题,会直接提示跳转到appstore。要求是实现安卓微信跳转显示一个页面,提示用手机自带的浏览器打开下载,就这么小修改了一下。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>download</title>
</head>
<div id="weixin-tip" style="margin: 0px; background: #0e0e0e;"></div>
<body>
<script>
goDownload();
function goDownload() {
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1;
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
if (isAndroid) {
if (is_weixn()) {
var weixin_tip = document.getElementById("weixin-tip");
var img = document.createElement("img");
img.src = "#";
weixin_tip.appendChild(img);
} else {
window.location.href = '#';
}
};
if (isIOS) {
window.location.href = '#';
}
}
function is_weixn() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
} else {
return false;
}
};
</script>
</body>
</html>
https://www.jianshu.com/p/f9db096857c2