sharonzahra — 2008-04-17T10:11:09-04:00 — #1
Hi I have a textarea with code text in it, and would like to have a link or button which when the user clicks on it, it will select ALL the code and copy it to the clipboard at the same time...
Can anyone help me?
I found this code which seems to work only in IE and it has something strange when I copy it to my HTML...link below...
alecrust — 2008-04-17T11:02:08-04:00 — #2
Give this a try:
<textarea name="text_area" rows="10" cols="80">
blah blah blah blah blah blah blah
sharonzahra — 2008-04-17T11:30:59-04:00 — #3
and to copy the text at the same when you click that button?
wuckfit — 2008-04-17T11:32:05-04:00 — #4
Firefox(Mozilla) doesn't allow this operation without enhanced privilages (editing prefs files, etc)...
MS is proprietry... window.clipboardData.setData(...) or document.execCommand('copy', false, null)
Opera/Safari... I'm not sure they support anything natively.
So you're best bet is flash... hope this helps.
alecrust — 2008-04-17T11:32:17-04:00 — #5
When you click the "Highlight Text" button it will select everything in the <textarea>.
wuckfit — 2008-04-17T12:21:26-04:00 — #6
alecrust — 2008-04-17T13:57:59-04:00 — #7
My fault sorry I thought that was all that was required.
sharonzahra — 2008-04-17T14:00:25-04:00 — #8
If no one else has an idea how to do it...can you refer to the flash thing to do this?
wuckfit — 2008-04-18T04:02:15-04:00 — #9
I've not had to implement this technique yet myself (but there is a project I'm working on that will require this functionality), so all I can do at the mo is point you in a direction
Hope this helps.