Search code examples
javascriptdojo

How would I implement 'copy url to clipboard' from a link or button using javascript or dojo without flash


I got stucked in implementing this feature on my web application. All the other possibilities are mostly by using flash content. Could someone explain how I can achieve it by using plain javascript or by Dojo.


Solution

  • I have been working on the exact same issue for a while. For me flash isn't a viable solution so I came up with this simple work around:

    <button onclick="prompt('Press Ctrl + C, then Enter to copy to clipboard','copy me')">Click to Copy</button>

    It requires some extra work on the users end but at least it doesn't require flash or external libraries.

    example fiddle