是否可以使用单击事件执行复制命令?
I have some text selected and I want this text to be copied on onClick
event, so that I am able to past this text to another page with out using right click or CTRL+C to copy the text.
function copyText(){
var txt = '';
if (window.getSelection)
txt = window.getSelection();
else if (document.getSelection)
txt = document.getSelection();
else return;
document.getElementById("a").value=txt;
allCopied =document.getElementById("a").createTextRange();
allCopied.execCommand("RemoveFormat");
allCopied.execCommand("Copy");
}
但出于安全原因大多数浏览器不允许修改剪贴板(除了IE浏览器).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)