HTML5 alternative to flash-based ZeroClipboard for safe copying of data to clipboard?

The reasoning is that automatic copying to clipboard can be very dangerous, thus most browsers (except IE)* make it difficult unless you use flash.

Much like your ZeroClipboard, there is Clipboard LMCButton which also uses a small flash script running in the background.

A common solution would be to do this:

 function copyToClipboard (text) {
     window.prompt ("Copy to clipboard: Ctrl+C, Enter", text);
 }

Which I found from Jarek Milewski when some one else asked the question here

*Yes I found one solution for IE, however does not work in most modern browsers, check here.

Update:

According to this: https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand Firefox 41+, Chrome 42+, and IE 9+ support the copy command with execCommand. For firefox and chrome it will only work if triggered by a user action such as a click, and for IE it will give the user a warning dialog asking them for permission to copy to the clipboard.

Leave a Comment