宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

上一次我发了一篇文章叫“微信打开网址添加在浏览器中打开提示”,里面我发出来了三个代码,分别是纯JS、JS+HTML、jQuery+HTML代码。今天来一个简化版带可以关闭的按钮操作。使用的是纯JS+HTML+CSS结合的方式,但不要一进入微信就弹出提示它在新浏览器中打开,在这个页面里面还可以提交表单查看信息等,只有它点击应用的链接后,才弹出提示它跳转后下载。

效果如下:

微信怎么设置在浏览器中打开APP下载链接-风君子博客

HTML代码:

<a id="J_weixin" class="android-btn" href="#"><img src="img/android-btn.png" alt="安卓版下载" /></a>
<div id="weixin-tip"><p><img src="img/live_weixin.png" alt="微信打开"/><span id="close" title="关闭" class="close">×</span></p></div>

CSS代码:

#weixin-tip{display:none;position:fixed;left:0;top:0;background:rgba0,0,0,0.8);filter:alphaopacity=80);width:100%;height:100%;z-index:100;}
#weixin-tip p{text-align:center;margin-top:10%;padding:0 5%;position:relative;}
#weixin-tip .close{color:#fff;padding:5px;font:bold 20px/24px simsun;text-shadow:0 1px 0 #ddd;position:absolute;top:0;left:5%;}

JS封装代码:

var is_weixin = function){return navigator.userAgent.toLowerCase).indexOf'micromessenger') !== -1}));
window.onload = function) {
	var winHeight = typeof window.innerHeight != 'undefined' ? window.innerHeight : document.documentElement.clientHeight; //容IOS
	var btn = document.getElementById'J_weixin');
	var tip = document.getElementById'weixin-tip');
	var close = document.getElementById'close');
	if is_weixin) {
		btn.onclick = functione) {
			tip.style.height = winHeight + 'px'; //容IOS
			tip.style.display = 'block';
			return false;
		}
		close.onclick = function) {
			tip.style.display = 'none';
		}
	}
}

演示

打开微信扫描看看效果吧。代码演示地址

微信怎么设置在浏览器中打开APP下载链接-风君子博客

很多人说这个看不懂,来看看这个更简单的:http://caibaojian.com/weixin-tip3.html