Easy Copy To Clipboard With JavaScript
Easy Copy To Clipboard With JavaScript
Advertisement

Simple module exposing copy function that will try to use execCommand with fallback to IE-specific clipboardData interface and finally, resort to usual prompt with proper text content and message.

Installation

  • Can be used as npm package and then leveraged using commonjs bundler/loader:
npm i --save copy-to-clipboard
  • Can be utilized using wzrd.in. Add following script to your page:
<script src=https://wzrd.in/standalone/[email protected] async></script>

Example

import copy from 'copy-to-clipboard';
 
copy('Text');
 
// Copy with options
copy('Text', {
  debug: true,
  message: 'Press #{key} to copy',
});

 

API documentation is available at the following link .

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.