为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Any possibility to read clipboard data using javascript in Firefox without user triggered ctrl+v event. Chrome prompts user for clipboard access permission.

more options

I am trying to read clipboard data using navigator.clipboard.readText() I get readText not a function whereas I can see that navigator.clipboard.writeText() is available. When I tried manually triggering ctrl+v I was able to access the data using event.clipboardData.getData().

I want a solution where the readText or getData should work without user intervention, provided the user is asked for permission before accessing clipboard, the way it happens in Chrome.

I am trying to read clipboard data using navigator.clipboard.readText() I get readText not a function whereas I can see that navigator.clipboard.writeText() is available. When I tried manually triggering ctrl+v I was able to access the data using event.clipboardData.getData(). I want a solution where the readText or getData should work without user intervention, provided the user is asked for permission before accessing clipboard, the way it happens in Chrome.

由swatimhatre16于修改

所有回复 (4)

more options

Clipboard.readText() is only supported for browser extensions in Firefox, not websites.

Clipboard.read() may work for you in the future, but it currently doesn't appear to be fully supported in Firefox and would also require the user to set the dom.events.asyncClipboard.dataTransfer preference to true.

It's a fairly new experimental feature, so it's not fully implemented by all browsers. Not to mention that it's pretty insecure to allow a website to read the user's clipboard without the user's knowledge.

more options

Post the config changes I was able to see the read function, but did not work programatically. Do you know till when will the feature be available to use in future.

more options

Post the config changes I was able to see the read function, but did not work programatically. Do you know till when will the feature be available to use in future.

more options

The Clipboard API is still a fairly new working draft specification. It's going to change frequently and possibly dramatically (in fact, the current draft was changed May 5, 2020) before it becomes an endorsed recommendation by W3C.

Until it's a recommendation (which could take a long time), it's still a non-standard feature that may fully supported in some browsers, but have partial or no support in others.