You can simply use jQuery to get the value of the original and paste it into the <textarea> like so: $("#copy"). click(function() { $("#paste").
The next most common work-around is to just place the clipboard-bound text into an input field, move the focus to that field and advise the user to press Ctrl + C to copy the text.
select() to select the contents of the <textarea> element. Use Document. execCommand('copy') to copy the contents of the <textarea> to the clipboard.
Copying to the clipboard is a tricky task to do in Javascript in terms of browser compatibility. The best way to do it is using a small flash. It will work on every browser. You can check it in this article.
Here's how to do it for Internet Explorer:
function copy (str)
{
//for IE ONLY!
window.clipboardData.setData('Text',str);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With