我正在为谷歌浏览器做一个扩展,我遇到了麻烦.
我需要在弹出窗口中单击将只读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."); }
Run Code Online (Sandbox Code Playgroud)