DEV Community

Keff
Keff

Posted on

Copy text to clipboard JS

Another snippet I tend to google each time I need it, copying to clipboard that is.

The demo does not work here, because "The Clipboard API has been blocked because of a permissions policy applied to the current document"

But you can find it, try it and use it from any of these places:


If you found the content useful, consider supporting me! I post some stuff around here, and have some stuff over on GitHub as well

Top comments (4)

Collapse
 
opeolluwa profile image
ADEOYE ADEFEMI OPEOLUWA

Thanks for this

Collapse
 
nombrekeff profile image
Keff

You're welcome, hope it's useful!

Collapse
 
dshakey profile image
dshakey

thanks for example. but interested in how to fix the "The Clipboard API has been blocked because of a permissions policy" issue.

Collapse
 
nombrekeff profile image
Keff

I don't think it's posible in this case, just how Iframes are set in dev.to, it only happens if running it from here.

I think you can configure your iframe in some way to allow that permission, but I'm not sure!