H5手机端调起并进入微信

发布时间:2020-12-02 22:13:05 浏览量:865 标签: 微信

最近在做营销类型的网站,有一个需求是点击微信咨询图标,进行弹窗操作,提示用户已经复制好了微信号了,前往微信进行添加好友功能。


我这是第一次做这样的功能,百度了很多办法都没有效果。目前网上最多的办法就是跳转链接:


window.location.href = 'weixin://'


经过我的测试,结果就是不好使没有办法了,只能自己思考如何去解决,通过查看网上资料,理解到了weixin://形式有很多种,都是调用微信不同方式的。既然本页面跳转不可行,那么新页面打开方式应该就可以了吧!


示例代码:

<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>H5调起微信示例代码</title>
    <style>
        .btn {
            padding: 6px 10px;
            text-align: center;
            border-radius: 5px;
            border: solid 1px #333;
            outline: none;
            cursor: pointer;
        }
    </style>
</head>
<body>

<button class="btn" id="open">点击调起微信</button>

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script>
    
    $("#open").click(function () {
        alert('即将调起微信');
        open('weixin://')
    });
</script>
</body>
</html>


测试地址:http://www.sybqsm.cn/weChat.html

测试方式:使用非微信浏览器访问链接并打开


评论
登录后才可以进行评论哦! QQ登录
验证码
评论内容