Skip to content

copyTextToClipboard

Mike Byrne edited this page Jan 25, 2022 · 2 revisions

description

Copies a string to the clipboard, if successful shows an alert with a message

requires

  • nothing

parameters

  • textToCopy - required - string of text to copy
  • successMsg - optional - string of text to display in the alert if successful, default says "Copied to clipboard"

returns

  • nothing

example usage:

var stringToCopy = "Hello World";
copyTextToClipboard(stringToCopy);

thanks to:

http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript#answer-30810322