wordpress 下载前判断是否是微信,如果是就提示在浏览器中打开

wordpress 季若尘 4年前 (2019-11-16) 526次浏览 已收录 0个评论 扫描二维码

演示页:

https://www.wmjrc.com/download.html?pid=2845

关键代码如下:

CS

 <div class="wxtip" id="JweixinTip">
    <span class="wxtip-icon"></span>
    <p class="wxtip-txt">点击右上角<br/>选择在浏览器中打开</p>
</div>
<style type="text/css">
	.wxtip{background:rgba(0,0,0,.8);text-align:center;position:fixed;left:0;top:0;width:100%;height:100%;z-index:999;display:none}
	.wxtip-icon{width: 52px; height: 67px; background: url(https://static.wmjrc.com/weixin-tip.png) no-repeat; display: block; position: absolute; right: 20px; top: 20px;}
	.wxtip-txt{margin-top: 107px; color: #fff; font-size: 16px; line-height: 1.5;}
</style>

JS

<script type="text/javascript">
	var ua = navigator.userAgent;
    var isWeixin =  !!/MicroMessenger/i.test(ua);
	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('dbtn');//下载一
    weixinTip(btn1);
    var btn2 = document.getElementById('dbtn2'); //下载二
    weixinTip(btn2);
</script>


版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:wordpress 下载前判断是否是微信,如果是就提示在浏览器中打开
喜欢 (2)
[]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址