js 实现复制功能的两种方法
文章目录
方法1:
var oInput = document.getElementById('input');
oInput.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
message.success("复制成功", 1);
方法2:
var dummy = document.createElement('input');
text = window.location.href;
document.body.appendChild(dummy);
dummy.value = text;
dummy.select(); // 选择对象
document.execCommand('copy'); // 执行浏览器复制命令
document.body.removeChild(dummy);

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论