微信下载引导
微信内置浏览器内不允许直接下载文件。如果是下载应用的话,可以上架到应用宝;不是应用的话 就需要做个提示,提示用户用浏览器打开。
代码如下:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>微信下载引导</title>
<style type="text/css">
/*演示用,请勿引入项目中*/
*{margin:0; padding: 0;}
body{font:normal 14px/1.5 Arial,Microsoft Yahei; color:#333;}
.example{padding: 20px;}
.example p{margin: 20px 0;}
a{display: inline-block; background: #61B3E6; color:#fff; padding: 0 10px; border-radius: 4px; text-align: center; margin: 0 5px; line-height: 22px; font-size: 14px; text-decoration: none;}
a.btn-warn{background: #F0AD4E;}
a:hover{opacity: 0.8;}
/*核心css*/
.wxtip{background: rgba(0,0,0,0.8); text-align: center; position: fixed; left:0; top: 0; width: 100%; height: 100%; z-index: 998; display: none;}
.wxtip-icon{width: 52px; height: 67px; background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAABDCAYAAADTXyaSAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABGFJREFUeNrcmmdoFEEUxyd69kSIgomxoUbsUSPWIGrUiJEQRRFBI9jFIDZsEcsH4wchoKKoEQ1YQYxixYIV/WCJiiKKCnbFErHGWC7xP+R/cC53l9292UtmH/yyl53Zvf3v23nvzexFlZeXCxdYS/AKlNVwgZhJ4IgUI/+J0txD9UAxtzXd4KG9FCOtnfyjs6BpYLTf/0k6C2oDthv2ddZZ0NEA+zrqKmiDzxsGS9Ixyg0Hp4K0eUGCTh7qYhDzw9Auw3YXXQTJi80Eu0E2SAbRIBUU/DeO5COnATVALcO+BaAxP2eAMnBZFw/JsuaPYV9/0I+fj4Hu4ILKoBAFWoEPAZ5vJ8bTM/Dd2KDCQ0vBeiDvzHHQFYwClymyJ2iqWFAemB+oIRxBMlMPBi/BO+7LArfAE5BPQdtAmmJBM8CWgC02BmgsiAZbwVAT/ZuAuqAQbFEQI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olute; right: 30px; top: 20px;}
.wxtip-txt{padding-top: 107px; color: #fff; font-size: 16px; line-height: 1.5;}
</style>
</head>
<body>
<div class="example">
<a id="New">点击下载APP</a>
<div class="wxtip" id="JweixinTip">
<span class="wxtip-icon"></span>
<p class="wxtip-txt">首次注册请点击右上角<br/>选择在浏览器中打开<br/>然后进行注册操作</p>
</div>
</div>
<script type="text/javascript">
function weixinTip(ele){
var ua = navigator.userAgent;
var isWeixin = !!/MicroMessenger/i.test(ua);
if(!isWeixin){
ele.onclick=function(e){
window.event? window.event.returnValue = false : e.preventDefault();
document.getElementById('JweixinTip').style.display='block';
}
document.getElementById('JweixinTip').onclick=function(){
this.style.display='none';
}
}
}
var btn1 = document.getElementById('New');
weixinTip(btn1);
</script>
</body>
</html>
页:
[1]