DEV Community

Discussion on: 💡 Easy Copy to Clipboard Button in Vanilla JavaScript

Collapse
 
aminnairi profile image
Amin

Hi there and thanks for your article. Copy to clipboard is a small, but powerful feature to have in a website in my opinion!

Unfortunately, it seems like this execCommand method from the global document object has been deprecated as per this doucmentation page on MDN.

You can use the new Clipboard API on newer browser which not only allow you to copy to the clipboard but also paste from it, and fallback to the old execCommand method in some old browser that does not yet support this new API.

Collapse
 
maxprogramming profile image
Max Programming

Thanks for the suggestion Amin. I haven't used the Clipboard API yet. I think it is very powerful. I will write another updated version of this article by using the Clipboard API.

Actually this was the easiest way I could find to copy the text so I wrote a tiny article about it to share my knowledge. Thanks again, I will check out the Clipboard API