195

The workflow is simple:

  1. You click inside a textarea.
  2. The text is copied to the client's clipboard.
  3. Display notice to the user.

How do you do it?

1
  • 7
    From what I understand, you can not access the clipboard without user action. The javascript clipboard functionality has been disabled in most current browsers as it is a possible security risk. You can use some of the dynamic flash overlay type stuff like zeroclipboard but can be kinda complicated and not always stable. I developed a flash element that you might want to look at text2clipboard.com, sorry about the plug but it works and I included helpful relevant info. Commented Jul 30, 2011 at 6:30

1 Answer 1

34

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); } 
Sign up to request clarification or add additional context in comments.

2 Comments

Is there one for firefox as well?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.