
You need to select the text and then execute the command copy to copy to the clipboard whatever text is currently selected on the page. There is another non-Flash way (apart from the Clipboard API mentioned in jfriend00's answer).

It will still work on many browsers, but its use is discouraged as support may be dropped. 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. As a developer, you’ll know how the clipboard works and regularly use the following keyboard shortcuts: Ctrl Cmd + C to copy Ctrl Cmd + X to cut Ctrl Cmd + V to paste Those with less. While that feature was fine at the moment of writing this answer, it is now considered obsolete.
Onclick put text clipboard update#
Update 2020: This solution uses execCommand.
