Standard “Copy” button found on many Internet sites. And everywhere they are implemented only in Flash. Unfortunately, the standard tools enable Javascript is not pressing the mouse to copy text to the clipboard. Therefore, in browsers with disabled Flash when you visit such sites ugly gray box appears in place of flash button.
For example, the site made in Flash Guthub button “Clone URL”.
Otherwise, it does not work copy the text from the form. A similar problem is widespread. But soon it will come to an end. Mozilla introduced in Firefox 41 supported commands copy
and cut
through document.execCommand. So did the IE and Chrome. It is called Flash-Free Clipboard.
Teams copy
and cut
called only in response to a user action, such as clicking a mouse button. Here is an example of a basic implementation in a web page.
// Button which we are attaching the event to
var button = ...;
// Input containing the text we want to copy
var input = ...;
button.addEventListener ("click", function (event) {
event.preventDefault ();
// Select the input node's contents
input.select ();
// Copy it to the clipboard
document.execCommand ("copy");
});
