So, as it was met / asked before I am trying to create a copy function that works on non-flash devices.
This led me to the clipboard API .
But I can not get it to work fine, this is what I still have:
$(function () {
$(document).on( 'click', '.copy-btn', function (e) {
var data = 'This has been copied';
var clip = new ClipboardEvent( 'copy' );
clip.clipboardData.setData( 'text/plain', data );
clip.preventDefault();
e.target.dispatchEvent( clip );
});
});
The code is clear enough, at the click of a button it should copy “This was copied” to the clipboard. Trying to do this I get:
"Uncaught ReferenceError: ClipboardEvent not defined." What am I missing? Shouldn't it be "embedded" or is there a need to call the API anyway?
Also came across this , which gives the same error.
Does this seem like a simple failure, or is the API currently not working?
source
share