Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clipboard-button

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clipboard-button

Copy text to clipboard by clicking a button, using only vanilla javascript without Flash.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

clipboard-button

Build Status Test Coverage

Copy text to clipboard by clicking a button, using only vanilla javascript without Flash. This is using the new Selection API and Clipboard API available in the latest browsers.

Browser support: Chrome 43+, Firefox 41+, Opera 29+ and IE10+.

See the demo.

Install

Install using npm or bower:

$ npm install clipboard-button --save
$ bower install clipboard-button --save

clipboard-button has no dependencies.

Usage

Create a button on your page, and specify the text you want to copy in the data-clipboard-text attribute:

<button id="myButton" data-clipboard-text="textToCopy">Copy</button>

Initialize clipboard-button by specifying a target button, either by a selector string or element instance:

function success() {
    console.log('Copied!');
};

function fail(err) {
    console.error('Error!', err);
};

var cpb = clipboardButton('#myButton', success, fail);

You can supply optional callback methods to be called for the success and error event. The error function will be called with the error object as first argument.

To clean up all event handlers and resources, you can call cpb.destroy().

To detect whether the browser is supported you can check the static property clipboardButton.supported.

Keywords

FAQs

Package last updated on 26 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc