手机端实现复制链接功能

来源:互联网 发布:新湖财富知乎 编辑:程序博客网 时间:2024/06/06 15:47

网上试了各种插件 总是不能兼容安卓和苹果的各种浏览器 目前兼容性不是很好 经测试只支持安卓HTML5的浏览器 后续如果有解决办法 又继续更新

_url : 要复制的链接
select_txt: 隐藏的input框 因为select()方法只能用于input和textarea框 所以相当于中间的一个媒介 把要复制的链接存放在select_txt中

//复制链接推荐function link(obj){    var _url = window.location.href;    $('#select_txt').val(_url);    console.log($('#select_txt').val());    var Url2=document.getElementById("select_txt");    Url2.select();     document.execCommand("Copy");     document.execCommand("Past");     $('.link').show();    hideSheet();}  
0 0
原创粉丝点击