Skip to main content
The 2024 Developer Survey results are live! See the results
added 2 characters in body
Source Link
Christophe Marois
  • 6.6k
  • 1
  • 32
  • 34

An answer that's a bit unusual: open a blank page from which the user will copy the text:

<a href="javascript:window.open('data:text/html, <html contenteditable>sup<script>document.execCommand('selectAll'\'selectAll\')</script></html>')">
  Copy the text “sup”
</a>

Just replace sup by the text you want the user to copy.

JS Bin example

An answer that's a bit unusual: open a blank page from which the user will copy the text:

<a href="javascript:window.open('data:text/html, <html contenteditable>sup<script>document.execCommand('selectAll')</script></html>')">
  Copy the text “sup”
</a>

Just replace sup by the text you want the user to copy.

JS Bin example

An answer that's a bit unusual: open a blank page from which the user will copy the text:

<a href="javascript:window.open('data:text/html, <html contenteditable>sup<script>document.execCommand(\'selectAll\')</script></html>')">
  Copy the text “sup”
</a>

Just replace sup by the text you want the user to copy.

JS Bin example

Source Link
Christophe Marois
  • 6.6k
  • 1
  • 32
  • 34

An answer that's a bit unusual: open a blank page from which the user will copy the text:

<a href="javascript:window.open('data:text/html, <html contenteditable>sup<script>document.execCommand('selectAll')</script></html>')">
  Copy the text “sup”
</a>

Just replace sup by the text you want the user to copy.

JS Bin example