admin管理员组

文章数量:1361960

I've developed a Firefox Addon which has a feature of copying some text automatically when the popup window is open. This works fine on Chrome, but it doesn't work in Firefox, and gives me this error message.

uncaught (in promise) DOMException: clipboard write was blocked due to lack of user activation.

I use the clipboard API to do this.

navigator.clipboard.writeText(data).then(()=>{
    console.log('copied')
})

Any thoughts to bypass this or fix this?

I've developed a Firefox Addon which has a feature of copying some text automatically when the popup window is open. This works fine on Chrome, but it doesn't work in Firefox, and gives me this error message.

uncaught (in promise) DOMException: clipboard write was blocked due to lack of user activation.

I use the clipboard API to do this.

navigator.clipboard.writeText(data).then(()=>{
    console.log('copied')
})

Any thoughts to bypass this or fix this?

Share Improve this question edited Nov 23, 2022 at 19:03 pbarney 2,8834 gold badges39 silver badges53 bronze badges asked Sep 23, 2021 at 17:53 ChethiyaKDChethiyaKD 9283 gold badges9 silver badges19 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

You extensions needs to have the clipboardWrite permission to write to the clipboard without user interaction. https://developer.mozilla/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboard_access

本文标签: javascriptHow to copy to clipboard on Firefox addon popup scriptStack Overflow