web 喚起qq相容safari
阿新 • • 發佈:2018-12-21
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title></title> 6 <style> 7 .link{display: none;} 8 .show{display: block;} 9 </style> 10 </head> 11 <body> 12 <a href="mqqwpa://im/chat?chat_type=wpa&uin=123456789&version=1&src_type=web&web_src=oicqzone.com"class="link a2 show">不是微信端</a> 13 <a href="http://wpa.qq.com/msgrd?v=3&uin=88888888&site=qq&menu=yes" class="link a1">微信端</a> 14 <script src="http://class.hflihe.com/orderos/js/jquery-3.1.0.min.js"></script> 15 <script> 16 function isWeiXin() { 17 varua = window.navigator.userAgent.toLowerCase(); 18 console.log(ua);//mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko)version/9.0 mobile/13b143 safari/601.1 19 if (ua.match(/MicroMessenger/i) == 'micromessenger') { 20 return true; 21 }22 else { 23 return false; 24 } 25 } 26 if(isWeiXin()){ 27 console.log(" 是來自微信內建瀏覽器"); 28 $(".a1").addClass("show"); 29 $(".a2").removeClass("show"); 30 } 31 else{ 32 console.log("不是來自微信內建瀏覽器"); 33 $(".a2").addClass("show"); 34 $(".a1").removeClass("show"); 35 } 36 </script> 37 </body> 38 </html>