Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js copy text to clipboard

// promise is returned for outcome;
// might require browser permissions;
// prefer this API as "execCommand" is deprecated
navigator.clipboard.writeText("some text").then(function() {
  /* clipboard successfully set */
}, function() {
  /* clipboard write failed */
});
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #js #copy #text #clipboard
ADD COMMENT
Topic
Name
2+4 =