How to copy text to the clipboard in Javascript?

The easiest thing to do at this point is to go with a Flash based solution. zeroclipboard is a common one (a nice walkthrough is available here).

Browser vendors have over the past few years removed programatic access to the clipboard. Safari / Chrome lost the ability after a change in WebKit, and FireFox for a long time has blocked it. Only IE remains as one that does allow it, however it displays an alert on each page initially.