Ok say you have this:
<input id="test" value="" />
Value of that input is dynamicly generated.
Now a user can double click on that input to select value, ctrl+c to copy.
I also found that with javascript you can select value of input with "click".
But when it comes to creating a button that when clicked will copy value of that input into OS's clipboard - i have found only solutions that works with Flash.
Now i want to know how can i create that button with javascript? Ofc if it is possible... :)
Whether it is a sample of code or it is the User's own information, we can create a copy button to copy data to the clipboard using the navigator. clipboard. writeText() function. This function writes the data fed to it as a parameter into the clipboard.
To copy and paste in Windows 10 using keyboard shortcuts, first select the item you want to copy. Then press Ctrl + C on your keyboard to copy.
Select the text you want to copy and press Ctrl+C. Place your cursor where you want to paste the copied text and press Ctrl+V.
Considering the implications (especially security concerns), copying to/from clipboard is not something that is quite allowed / easy.
Those questions / answsers might help you, about that :
In each case, it seems that the solution is to use some little .swf file -- which means working with flash (maybe some old version of flash, actually)...
For instance, you could take a look at the Zero Clipboard library (yeap, flash...) :
The Zero Clipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie, and a JavaScript interface. The "Zero" signifies that the library is invisible and the user interface is left entirely up to you.
This library is fully compatible with Flash Player 10, which requires that the clipboard copy operation be initiated by a user click event inside the Flash movie. This is achieved by automatically floating the invisible movie on top of a DOM element of your choice.
In pure Javascript, it seems to be possible in Internet Explorer, but not in other browsers...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With