Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add "clipboard-write" permission to navigator?

I am maintaining an app written in Angular and launched on chromium (desktop app), i am trying to copy to clipboard some text and i used

navigator.clipboard.writeText(result)

Unfortunately, it didn’t work because and i don’t have "clipboard-write" permission on the navigator.

How to add permission "clipboard-write" to the navigator or is there any other solution to copy the text to the clipboard ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

How to add permission "clipboard-write" to the navigator?

Permissions are not something that you (as the developer) control. They are entirely within the control of the user and user agent (browser). If the user decides not to grant (or revoke) a permission, then your app simply cannot perform actions which require it.

I’ll inline some documentation from the MDN article for Clipboard.writeText():

Security

Transient user activation is required. The user has to interact with the page or a UI element in order for this feature to work.

The "clipboard-write" permission of the Permissions API is granted automatically to pages when they are in the active tab.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading