Simply click Copy, as if many websites have the copy code button. However, it seems that many Browsers Do not support flash. Now, how to solve this problem is to simply click Copy, as if many websites have this button. But it seems that many Browsers Do not support flash. How can this problem be solved now?
Reply content:
Just click Copy. It seems that many websites have this button. But it seems that many Browsers Do not support flash. How can this problem be solved now?
For long ago, flash needs to be introduced to access the clipboard by calling the flash api, Which is disgusting. Now, abyun does not recommend flash itself, so there is a natural way.
Https://zenorocha.github.io/clipboard.js/
Depende onSelection
Anddocument.execCommand
API
SCRIPT function CopyAll (T) {T. focus () T. select () if (document.all?therange=t.createtextrange(thertherange.exe cCommand ("Copy") // Copy} SCRIPT(Content test)(You can paste the content here)
He JavaScript document.exe cCommand ('copy') support has grown, see the links below for browser updates:
IE10 + (although this document indicates some support was there from IE5.5 + ).
Google Chrome 43 + (~ April 2015)
Mozilla Firefox 41 + (shipping ~ September 2015)
Opera 29 + (based on Chromium 42 ,~ April 2015)
Simple Example
Var copyTextareaBtn = document. querySelector ('. js-textareacopybtn ');
CopyTextareaBtn. addEventListener ('click', function (event ){
Var copyTextarea = document. querySelector ('. js-copytextarea ');
CopyTextarea. select ();
Try {
var successful = document.execCommand('copy');var msg = successful ? 'successful' : 'unsuccessful';console.log('Copying text command was ' + msg);
} Catch (err ){
console.log('Oops, unable to copy');
}
});
Hello I'm some text
Copy Textarea
See http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript