Simon Griffee

Copy to Clipboard

18 June 2013 · 1 minute read

This is great. No Flash, educates users, works in any GUI web browser.

Here is the full HTML & JavaScript code I used:

<p>
    <b>URL of this page</b> <small>(To copy: Click, <kbd>Ctrl/Cmd-C</kbd>, <kbd>Enter</kbd>)</small>
    <br>
    <a href="" onclick="window.prompt('Press Ctrl+C (Cmd+C for Mac) and then Enter', text);" title="Click, press Ctrl+C and then Enter to copy to clipboard.">http://theurl.tld</a>
</p>

Which becomes:

URL of this page (To copy: Click, Ctrl/Cmd-C, Enter)
http://theurl.tld

What

Share