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.
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
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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 globaldocument
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.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