js手写的弹出框
发布时间:2022-10-17 22:31:01 284 相关标签: # javascript# java# java# 设备
function cpData() {
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {//区分iPhone设备
window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
var Url2=document.getElementById("copyInput");//要复制文字的节点
var range = document.createRange();
// 选中需要复制的节点
range.selectNode(Url2);
// 执行选中元素
window.getSelection().addRange(range);
// 执行 copy 操作
document.execCommand('copy');
}else{
var Url2=document.getElementById("copyInput");
Url2.select();
if (document.execCommand('copy')) {
document.execCommand('copy');
}
}
}
document.execCommand('Copy')
文章来源: https://blog.51cto.com/u_14351881/5630088
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报