Advertisement
stuppid_bot

Copy To Clipboard // from Avast extension

Feb 14th, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.      * Copy text provided into clipboard.
  3.      * @param {String} text to copy to clipboard
  4.      */
  5.     copyToClipboard : function (text) {
  6.       var body = document.getElementsByTagName('body');
  7.       if (body.length > 0) {
  8.         body = body[0];
  9.         var copyFrom = document.createElement('textarea');
  10.         copyFrom.value = text;
  11.         body.appendChild(copyFrom);
  12.         copyFrom.select();
  13.         document.execCommand('copy', true);
  14.         copyFrom.parentNode.removeChild(copyFrom);
  15.       }
  16.     },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement