As mentioned here:
To use the API in iframes, you need to enable it with Permissions Policy, which defines a mechanism that allows for selectively enabling and disabling various browser features and APIs. Concretely, you need to pass either or both of
clipboard-read
orclipboard-write
, depending on the needs of your app.
<iframe src="index.html" allow="clipboard-read; clipboard-write"></iframe>
If you only want to be able to copy text to the clipboard (i.e. you don’t need to be able to read the clipboard programmatically), then you only need the clipboard-write
permission:
<iframe src="index.html" allow="clipboard-write"></iframe>