If I copy an html table manually, I can paste it into a Google Doc with the formatting preserved (it looks like a table).
How can I copy the contents programmatically, with a button, and paste as an html table? Something like the following...
evar copydeck = $("<div>").html(htmlToInsert);
$('body').append(copydeck);
copydeck.select();
document.execCommand('copy');
copydeck.remove();
The above code does not work...but this does:
copydeck = $("<textarea>").val(this.list.join("
"));
$('body').append(copydeck);
copydeck.select();
document.execCommand('copy');
copydeck.remove();
I guess it is because the element must be selectable - like an input or htmlarea field. But they can't hold html (or it is just plain text, not html).
Any way to copy and paste HTML?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…