看到一个最新跳转QQ添加好友代码JavaScript代码,感觉有趣,就分享一下,觉得有用的,自行测试哦!!!
代码:
function addCustomerService() {
const params = new URLSearchParams(window.location.search);
const qq = params.get('qq');
if (!qq) {
alert('未传入客服qq号');
} else {
var ua = navigator.userAgent;
var isIphone = ua.match(/(iPhonesOS)s([d_]+)/),
isAndroid = ua.match(/(Android)s+([d.]+)/);
if (isIphone) {
location.href = `mqq://card/show_pslcard?src_type=internal&version=1&uin=${qq}&card_type=person&source=sharecard`;
} else if (isAndroid) {
location.href = `mqq://card/show_pslcard?src_type=internal&version=1&uin=${qq}&card_type=person&source=sharecard`;
} else {
location.href = `tencent://AddContact/?fromId=45&fromSubId=1&subcmd=all&uin=${qq}`;
}
}
}
window.onload = function () {
addCustomerService();
};
比如我们的网址是 https://wep.vipyshy.com/qq.html?qq=123456,此时addCustomerService方法内的params变量值为qq=123456,qq的值为123456。
移动端则跳转到:mqq://card/show_pslcard?src_type=internal&version=1&uin=123456&card_type=person&source=sharecard
电脑端则跳转到:tencent://AddContact/?fromId=45&fromSubId=1&subcmd=all&uin=123456
评论