⬅️ JavaScript

Async Clipboard API [navigator.clipboard.writeText]

  • Text can be copied to the clipboard directly from a variable.
  • Only supported on pages served over HTTPS.
  • In Chrome 66 pages inactive tabs can write to the clipboard without a permissions prompt.
var text = "Example text to appear on clipboard";
navigator.clipboard.writeText(text).then(function() {
  console.log('Async: Copying to clipboard was successful!');
}, function(err) {
  console.error('Async: Could not copy text: ', err);
});