网页添加QQ和微信跳转

 


<p>QQ:</p>
<a href="javascript:;" onclick="go_fn('qq','819344241')" target="_blank" title="马上联系QQ">819344241</a><br>
<p>微信:</p>
<a href="javascript:;" onclick="go_fn('wx','e0346g')" target="_blank" title="马上联系微信">e0346g</a><br>
<p>Skype:</p>
<a href="javascript:;" onclick="go_fn('sk','954334423@qq.com')" target="_blank" title="马上联系Skype">
        954334423@qq.com</a>
<p>纸飞机:</p>
<a href="javascript:;" onclick="go_fn('te','@Ybdaili')" target="_blank" title="马上联系Telegram">&nbsp;@Ybdaili</a>
<p>邮箱:</p>
<a href="javascript:;" onclick="go_fn('em','affhuohu@gmail.com')" target="_blank"
        title="马上联系邮箱">&nbsp;affhuohu@gmail.com</a>

// 联系方式在线沟通
    // 判断电脑端 、 手机端
    let web_type = false; // 默认电脑端
    if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))) { // 手机端
        web_type = true;
    }

    function go_fn(type, id) {
        switch (type) {
            case 'qq':
                if (web_type) {
                    window.location.href = `mqqwpa://im/chat?chat_type=wpa&uin=${id}&version=1&src_type=web`;
                } else {
                    window.location.href = `tencent://message/?uin=${id}&Menu=yes`;
                }
                break;

            case 'wx':
                window.location.href = `tencent://message/?uin=${id}`;
                break;

            case 'sk':
                window.location.href = `skype:${id}?call`;
                break;

            case 'te':
                window.location.href = `https://t.me/${id}`;
                break;

            case 'em':
                window.location.href = `mailto:${id}`;
                break;
        }
    }

评论