js复制内容,兼容所有浏览器

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ltx06/article/details/80151475

大概思路:

创造一个新的节点,用完后删除

var oInput = document.createElement('input');
oInput.value = '复制内容';
document.body.appendChild(oInput);
oInput.select();//选择对象
document.execCommand('copy');//执行浏览器复制命令
document.body.removeChild(oInput);

猜你喜欢

转载自blog.csdn.net/ltx06/article/details/80151475