网页里打开微信或者qq
一,H5端:
手机端:
<a href="mqqwpa://im/chat?chat_type=wpa&uin=840937370&version=1&src_type=web&web_src=oicqzone.com">打开qq聊天框</a>
<a href="weixin://profile/CESVjbDE9e2KrfTu9xEa">微信方法二-浏览器中打开</a>
<a href="weixin://qr/CESVjbDE9e2KrfTu9xEa">微信方法三-浏览器中打开</a>
<a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=YHWno5vEoVPdKd-AbyDk==&scene=110==#wechat_redirect">微信方法四-微信中打开窗口</a>
PC端:
<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=840937370&site=qq&menu=yes"> QQ</a>
<a href="tencent://message/?uin=840937370&Site=Sambow&Menu=yes">QQ</a>
<a href="https://qm.qq.com/cgi-bin/qm/qr?k=qQ2eY_xca3Q_Eks57x9Gh-dtSUVzuZ_K&authKey=fBfHpGZYecH6NxVbH%2B%2B55AdP2fucjyWuNlB9sGYPgidOzM3eVe5vJXW57%2BuiYLlG&noverify=0&group_code=832929820">QQ群</a>
注:k值请见https://qun.qq.com/join.html
二,js端:
1 <!doctype html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>手机与电脑浏览器打开qq或微信客服</title>
6 <script type="text/javascript">
7 // 跳转到qq
8 function openQQ(){
9 var sUserAgent = navigator.userAgent.toLowerCase();
10 var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
11 var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
12 var bIsMidp = sUserAgent.match(/midp/i) == "midp";
13 var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
14 var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
15 var bIsAndroid = sUserAgent.match(/android/i) == "android";
16 var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
17 var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
18 if(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
19 window.open("mqqwpa://im/chat?chat_type=wpa&uin=840937370&version=1&src_type=web&web_src=oicqzone.com");
20 } else {
21 window.open("tencent://message/?uin=840937370&Site=Sambow&Menu=yes");
22 }
23 }
24
25 // 跳转到微信
26 function openWeChat(){
27 var sUserAgent = navigator.userAgent.toLowerCase();
28 var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
29 var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
30 var bIsMidp = sUserAgent.match(/midp/i) == "midp";
31 var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
32 var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
33 var bIsAndroid = sUserAgent.match(/android/i) == "android";
34 var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
35 var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
36 if(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
37 window.open("weixin://profile/CESVjbDE9e2KrfTu9xEa");
38 } else {
39 window.open("https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=YHWno5vEoVPdKd-AbyDk==&scene=110==#wechat_redirect"); // 我不会打开电脑端窗口,这里用的在微信浏览器里打开的,有会的告诉我下。
40 }
41 }
42 </script>
43 </head>
44
45 <body>
46 <div>
47 <a href="mqqwpa://im/chat?chat_type=wpa&uin=840937370&version=1&src_type=web&web_src=oicqzone.com" class="qq">手机QQ</a>
48 <a href="tencent://message/?uin=840937370&Site=Sambow&Menu=yes">电脑QQ</a>
49
50 <a id="qq" href="javascript:void(0);" onclick="openQQ()">QQjs</a>
51
52 <a href="weixin://profile/CESVjbDE9e2KrfTu9xEa">手机微信</a>
53
54 <a id="WeChat" href="javascript:void(0);" onclick="openWeChat()">微信js</a>
55 </div>
56 </body>
57 </html>
本文来自博客园,作者:꧁执笔小白꧂,转载请注明原文链接:https://www.cnblogs.com/qq2806933146xiaobai/p/14523856.html