https://github.com/andreruffert/clipboard.js
:clipboard: Handle clipboard data with JavaScript in the browser.
https://github.com/andreruffert/clipboard.js
Last synced: 3 months ago
JSON representation
:clipboard: Handle clipboard data with JavaScript in the browser.
- Host: GitHub
- URL: https://github.com/andreruffert/clipboard.js
- Owner: andreruffert
- License: mit
- Created: 2015-07-16T15:42:52.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-07-21T09:25:39.000Z (almost 10 years ago)
- Last Synced: 2025-02-17T21:09:28.217Z (4 months ago)
- Language: HTML
- Homepage: http://andreruffert.github.io/clipboard.js/
- Size: 145 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clipboard.js (beta)
> Copy to the clipboard with JavaScript \o/
This is a work in progress so the exported functions could change at any time before the first stable release (1.0.0).
## Browser Support
* IE10+ (although [this document](https://msdn.microsoft.com/en-us/library/ms537834(v=vs.85).aspx) indicates some support was there from IE5.5+).
* [Google Chrome 43+ (~April 2015)](https://developers.google.com/web/updates/2015/04/cut-and-copy-commands)
* [Mozilla Firefox 41+ (shipping ~September 2015)](https://developer.mozilla.org/en-US/Firefox/Releases/41#Interfaces.2FAPIs.2FDOM)
* [Opera 29+ (based on Chromium 42, ~April 2015)](https://dev.opera.com/blog/opera-29/#cut-and-copy-commands)## Usage
```js
var myElement = document.querySelector('.myElement');clipboard(myElement, 'copy');
//=> 'Some text'clipboard(myElement, 'copy', function(err, copiedText) {
//...
});
//=> 'Some text'var myFormElement = document.querySelector('.myFormElement');
clipboard(myFormElement, 'cut');
//=> 'Value from the form element'clipboard(myFormElement, 'cut', function(err, copiedText) {
//...
});
//=> 'Value from the form element'
```## API
### clipboard(element, cmd, [callback])
Returns the copied text.
#### element
_Required_Type: `Element`
Element which text will be copied.
#### cmd
_Required_Type: `String`
Currently supports 'cut' and 'copy'.
#### callback
Type: `Function````
function(err, copiedText) {}
```## License
MIT © [André Ruffert](http://andreruffert.com)