功能:用微信扫描二维码时,会提示跳转到浏览器中
制作过程:写一个html页面,放到服务器上生成网址,在生成二维码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>打开浏览器</title>
<style>
</style>
</head>
<body>
<div id="container" style="display: none;">
<div style='position:relative;padding-top:100px;color:#333;font-size: 22px;text-align: center;'>
<i style='position: absolute;top: 10px;right: 10px;font-size: 100px' class='iconfont icon-jiantou'></i>
<p style="font-weight: 600;">请点击屏幕右上角 [ ··· ] </p>
<p>在浏览器打开</p>
</div>
</div>
<script>
var browser = {
versions: function () {
var u = navigator.userAgent, app = navigator.appVersion;
return {//移动终端浏览器版本信息
trident: u.indexOf('Trident') > -1, //IE内核
presto: u.indexOf('Presto') > -1, //opera内核
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/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部
wx: u.indexOf("MicroMessenger") > 0 //是否是微信
};
}(),
language: (navigator.browserLanguage || navigator.language).toLowerCase()
}, con = document.getElementById("container");
if (browser.versions.wx) {
con.style.cssText = "display:block";
window.location.href= 'https://api.huanuowei.cn/data/upload/app/11.apk';
} else if (browser.versions.android) {
// 此处写Andoird 的下载地址
window.location = "https://api.huanuowei.cn/data/upload/app/11.apk";
} else if (browser.versions.ios || browser.versions.iPhone || browser.versions.iPad) {
alert("iOS暂不支持下载哦~");
//TODO 此处写ios的下载地址
window.location = "";
} else {
window.location = "https://api.huanuowei.cn/data/upload/app/11.apk";
}
</script>
</body>
</html>