Copy clipboard don't work in an iframe

Hello, I developed a password generator for my company with next js, my company wants me to integrate it in the wix site, so I found no other solution than to try to do it with an iFrame.

Everything works except the “copier” button that allows you to copy to the clipboard the password. I have this error that appears in the console:

"Uncaught (in promise) DOMException: The Clipboard API has been blocked because of a permissions policy applied to the current document. See Deprecating Permissions in Cross-Origin Iframes - The Chromium Projects for more details. "

I did these tests on this test site:

I did a lot of research but none of the solutions I found worked.

Here’s how I did it on wix side :

Hi, make the iframe post the text to the parent page and have it automatically copy from there.$w/htmlcomponent/onmessage

Alternatively, create the iframe using custom element so it won’t be sandboxed.

1 Like

I don’t understand how am I supposed to do this

@yanislebzar7 Read the 2 doc at the links I posted above, try to implement it, and if it doesn’t work for some reason, post your code.

@jonatandor35 Thanks, that’s actually working !

1 Like