Originally posted on my blog
As a developer, we know how useful and good it is to have a "copy" button sitting next to a code block. In some cases...
For further actions, you may consider blocking this person and/or reporting abuse
I made a simple library to facilitate that work, you can check and contribute in github.com/assisfery/CopyPasteJS
cool. looking forward to giving it a try
Just curious: What exactly are the 5 lines of code?
That's the code that does the copy.
You could also use the browser Clipboard API - "navigator.clipboard"
Yeah it's a great one. But it's still not supported by all browsers.
That's the only one to use to be honest, and according to caniuse, all browsers support it except Opera Mini and UC Browser for Android.
Had no idea it was that easy 🤯. Love the addition of the code pen.
I'm glad you find value on it.
Cool)
👍
First, be sure that you review browser compatibility that you are supporting.
Also, one thing is getting data from the clipboard and putting it on it, that is very different to implement.
According to Can I Use 93.39% of browsers support this method.
And to paste something on the input field just do this
document.execCommand("paste")
Also there is a handy, lightweight library for this
Thanks for sharing the resource