pc 用
<a href="http://wpa.qq.com/msgrd?v=3&uin=3048069311&site=qq&menu=yes" target="_blank" class="call_us">在线咨询</a>
移动端
移动端浏览器和微信还是不一样
注:
<a href="http://wpa.qq.com/msgrd?v=3&uin=3048069311&site=qq&menu=yes" target="_blank" class="call_us">在线咨询</a>
可以兼容微信浏览器 兼容安卓移动端浏览器 部分ios设备 浏览器调不起(iphone xr ,iphone 8 p等 ) 方法如下:
可以解决部分 ios 浏览器调不起qq(直接打开了APP store)
<a href="mqq://im/chat?chat_type=wpa&uin=3048069311&version=1&src_type=web" target="_blank" class="call_us">在线咨询</a>
完美方案 兼容各种
判断一下是微信浏览器还是手机浏览器
var ua = window.navigator.userAgent.toLowerCase();
//判断userAgent
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
$('.call_us').attr('href', 'http://wpa.qq.com/msgrd?v=3&uin=3048069311&site=qq&menu=yes');
}else{
$('.call_us').attr('href','mqq://im/chat?chat_type=wpa&uin=3048069311&version=1&src_type=web');
}
这里封装了一个方法
<a href="javascript:concat('527395639');" class="zixun_btn">立即咨询</a>
<a href="" class="none concat_btn1" target="_blank"></a>
function concat(qq) {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
var ua = window.navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == 'micromessenger') {
$('.concat_btn1').attr('href', 'http://wpa.qq.com/msgrd?v=3&uin=' + qq + '&site=qq&menu=yes');
$('.concat_btn1')[0].click();
} else {
$('.concat_btn1').attr('href', 'mqq://im/chat?chat_type=wpa&uin=' + qq + '&version=1&src_type=web');
$('.concat_btn1')[0].click();
}
} else {
$('.concat_btn1').attr('href', 'http://wpa.qq.com/msgrd?v=3&uin=' + qq + '&site=qq&menu=yes');
$('.concat_btn1')[0].click();
}
}
网友评论