I have a textarea that includes information. It has an onfocus attribute which selects all text inside it automatically (onfocus=”this.select();). I want that when I focus on the textarea, all the selected text get’s automatically copied to my clipboard, so I can easily paste it anywhere without having to right click to copy or pressing CTRL + C. How would this be done?
I have a textarea that includes information. It has an onfocus attribute which selects
Share
For security reasons, JavaScript can’t access the clipboard.
If you really want to do it, you must use flash (flash can write into the clipboard, but not read).
Yet, you need to click inside flash to write into clipboard (but it can be simulated).
You can see it being done in Pastebin (Copy to Clipboard).
If you really want to do it, I recommend you to use Zero Clipboard.
Notice that your actual approach is used by Google URL Shortener (try shorten a url).
Tell us your decision.