gotem
Copy to clipboard for modern browsers in less than 1kb.
Install
$ npm i gotem --save
Use
gotem
is a function that accepts 3 parameters:
- A required trigger node.
- A required target node.
- An optional object of callback functions.
Examples follow:
// a trigger and target node are requiredconst nodes = trigger: document target: document // when the trigger is clicked,// the text of the target will be copied to the clipboard // if an object with callback functions (success, error) is passed,// the appropriate function, based on the result of executing the copy command, will be fired if it exists
Browser Support
gotem requires execCommand
cut/copy support.
As such, it works in the following:
- Chrome 43+
- Firefox 41+
- Safari 10+
- Edge 12+
- IE 9+
License
MIT. © 2017 Michael Cavalea