Is it possible to create instance of ClipboardEvent in Chrome?

丶灬走出姿态 提交于 2019-12-03 11:21:54

问题


I need to programmatically create a ClipboardEvent instance in Chrome.

But when I run the constructor:

new ClipboardEvent("paste", {dataType: "text/plain", data: "some data"})

It throws the following error:

Uncaught TypeError: Illegal constructor

The constructor works as intended in Firefox.

Checked MDN and W3C spec and they don't mention anything about it being illegal to create instances of ClipboardEvent.

Is it possible to create an instance of ClipboardEvent in Chrome in any other way? I prefer to not mock a custom ClipboardEvent when one exists.

Update 2018-07-17: Using the ClipboardEvent seems to work in Chrome 69.


回答1:


Unfortunately, it's not. This is from http://caniuse.com/#feat=clipboard

Partial support in IE refers using a non-standard method of interacting with the clipboard. For other browsers it refers to not supporting the ClipboardEvent constructor.

Unfortunately, the only browser that properly supports the Clipboard API is FireFox (since 22). All other browsers (if it supports Clipboard API at all), will not support the ClipbordEvent constructor.



来源:https://stackoverflow.com/questions/28861479/is-it-possible-to-create-instance-of-clipboardevent-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!