我正在为Google Chrome开发扩展程序,但遇到了一个难题。
我需要在单击弹出窗口中的readonly textarea时将其内容复制到剪贴板中。有没有人知道使用纯JavaScript且不使用Flash的最佳方法?如果可以的话,我也加载了jQuery库。我的当前(不起作用的)代码是...
function copyHTMLCB() {
$('#lb_html').select();
$('#lb_html').focus();
textRange = document.lb_html_frm.lb_html.createTextRange();
textRange.execCommand("RemoveFormat");
textRange.execCommand("Copy");
alert("HTML has been copied to your clipboard."); }
document.body
而是要用var body = document.getElementsByTagName('body')[0];
呢? - jscripterdocument.body.removeChild(copyFrom)
?而不是用copyFrom.remove()
呢?这样做不更容易吗? - Shayan