1. 程式人生 > >微信中該如何使用外部瀏覽器打開指定網頁html鏈接

微信中該如何使用外部瀏覽器打開指定網頁html鏈接

return android posit undefine avi rfi lang lse sdn

技術分享圖片 使用微信打開網址時,無法在微信內打開常用下載軟件,手機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

微信中該如何使用外部瀏覽器打開指定網頁html鏈接