微信中该如何使用外部浏览器打开指定网页html链接

 

标题

使用微信打开网址时,无法在微信内打开常用下载软件,手机APP等。
解决方案弹出一个遮罩提示用户在新的浏览器窗口打开。

使用的是纯JS+HTML+CSS结合的方式,但不要一进入微信就弹出提示它在新浏览器中打开,在这个页面里面还可以提交表单查看信息等,只有它点击应用的链接后,才弹出提示它跳转后下载。

 

 
  1.  

    <a id="J_weixin" class="android-btn" href="#"><img src="img/android-btn.png" alt="安卓版下载" /></a>

  2.  

    <div id="weixin-tip"><p><img src="img/live_weixin.png" alt="微信打开"/><span id="close" title="关闭" class="close">×</span></p></div>

 

 
  1.  

    #weixin-tip{display:none;position:fixed;left:0;top:0;background:rgba(0,0,0,0.8);filter:alpha(opacity=80);width:100%;height:100%;z-index:100;}

  2.  

    #weixin-tip p{text-align:center;margin-top:10%;padding:0 5%;position:relative;}

  3.  

    #weixin-tip .close{color:#fff;padding:5px;font:bold 20px/24px simsun;text-shadow:0 1px 0 #ddd;position:absolute;top:0;left:5%;}

 

 

 

 

 
  1.  

    var is_weixin = (function(){return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1})();

  2.  

    window.onload = function() {

  3.  

    var winHeight = typeof window.innerHeight != 'undefined' ? window.innerHeight : document.documentElement.clientHeight; //兼容IOS,不需要的可以去掉

  4.  

    var btn = document.getElementById('J_weixin');

  5.  

    var tip = document.getElementById('weixin-tip');

  6.  

    var close = document.getElementById('close');

  7.  

    if (is_weixin) {

  8.  

    btn.onclick = function(e) {

  9.  

    tip.style.height = winHeight + 'px'; //兼容IOS弹窗整屏

  10.  

    tip.style.display = 'block';

  11.  

    return false;

  12.  

    }

  13.  

    close.onclick = function() {

  14.  

    tip.style.display = 'none';

  15.  

    }

  16.  

    }

  17.  

    }

 

效果图:

源码参考:http://blog.csdn.net/netuser1937/article/details/73647909

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值