How can I mimic CTRL+A, CTRL+C in WebBrowser Control through COM or JavaScript?
How can I mimic CTRL+A, CTRL+V in WebBrowser Control automatically via COM?
Alternatively, is there a way o开发者_如何学运维f simulating this behaviour using JavaScript?
I looked all over and it seems that the only way to put data into the clipboard is to use the setData()
method of the clipboardData
object, but I end up with HTML being interpreted as text. What I need is to put an entire webpage into the clipboard so it can be pasted into MS Word.
This answer was discovered by the OP and posted as an update to the question. Just moving it here for semantics.
Here's the solution in JavaScript (can be used through COM as well):
window.document.execCommand('SelectAll',true);
window.document.execCommand('Copy',true);
window.document.execCommand('UnSelect',true);
精彩评论