Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Copy text provided into clipboard.
- * @param {String} text to copy to clipboard
- */
- copyToClipboard : function (text) {
- var body = document.getElementsByTagName('body');
- if (body.length > 0) {
- body = body[0];
- var copyFrom = document.createElement('textarea');
- copyFrom.value = text;
- body.appendChild(copyFrom);
- copyFrom.select();
- document.execCommand('copy', true);
- copyFrom.parentNode.removeChild(copyFrom);
- }
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement