Advertisement

How to copy text contents in body to clipboard

I need to copy all the text in my body to the clipboard, here is what I've tried so far:
  • selecting the text nodes and then the command document.execCommand("copy")
  • selecting the text nodes and then using the keyboard dispatcher:

    $("body").contents().filter(function(){return this.nodeType === 3;}).select();  document.body.dispatchEvent(new KeyboardEvent("keyup", {bubbles: true, cancelable: false, key: "C", char: "C", ctrlKey: true}));  

No errors pop up. I've read in the Chromium documentation that the copy command is disabled for security reasons. Any idea how to get around this?

Post a Comment

0 Comments