近期,有建网站客户要求实现在自己的手机网站上实现点击复制微信号并自动打开微信加好友的功能。怎么在自己建网站时,制作出这样的点击复制微信号并自动打开微信加好友功能呢?
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script> <script src="https://cdn.jsdelivr.net/clipboard.js/1.5.12/clipboard.min.js"></script> <title>复制按钮</title> </head> <body> 微信号:<span id="target">qinghuadns</span> <button data-clipboard-action="copy" data-clipboard-target="#target" id="copy_btn"> 点击复制 </button> </body> <script> $(document).ready(function(){ var clipboard = new Clipboard('#copy_btn'); clipboard.on('success', function(e) { alert("微信号复制成功",1500); window.location.href='weixin://微信号'; e.clearSelection(); console.log(e.clearSelection); }); }); </script> </html>
扫描二维码手机查看该文章
文章引用:https://www.qinghuahulian.com/news/webzhishi/1354.html