您的位置:首页 > 移动开发 > 微信开发

进入微信后提示用浏览器打开

2018-01-10 19:36 274 查看
先展示下效果:



第一步:css样式

<style type="text/css">
*{
margin:0;
padding:0;
}
a{
text-decoration: none;
}
img{
max-width: 100%;
height: auto;
}
.weixin-tip{
display: none;
position: fixed;
left:0;
top:0;
bottom:0;
background: rgba(0,0,0,0.8);
filter:alpha(opacity=80);
height: 100%;
width: 100%;
z-index: 100;
}
.weixin-tip p{
text-align: center;
margin-top: 10%;
padding:0 5%;
}
</style>

第二步:html
代码:

<div class="weixin-tip">
<p>
<img src="live_weixin.png" alt="微信打开"/>
</p>
</div>

第三步:js代码

<script type="text/javascript">
$(window).on("load",function(){
var winHeight = $(window).height();
function is_weixin() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
} else {
return false;
}
}
var isWeixin = is_weixin();
if(isWeixin){
$(".weixin-tip").css("height",winHeight);
$(".weixin-tip").show();
}
})
</script>
完成!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息