问题描述
我需要以编程方式在Chrome中创建一个ClipboardEvent实例。
但是当我运行构造函数时:
new ClipboardEvent(paste,{dataType:text / plain,data:some data})
它会抛出以下错误:
未捕获的TypeError:非法的构造函数
构造函数在Firefox中按照预期工作。
选中和,并且他们没有提及创建ClipboardEvent实例是非法的。
是否有可能以任何其他方式在Chrome中创建ClipboardEvent的实例?我更喜欢在存在自定义ClipboardEvent时模拟它。
不幸的是,唯一正确支持 Clipboard API的浏览器
是FireFox(自22以来)。所有其他浏览器(如果它支持剪贴板API)将不支持ClipbordEvent构造函数。
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.
Unfortunately, it's not. This is from http://caniuse.com/#feat=clipboard
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.
这篇关于是否可以在Chrome中创建ClipboardEvent的实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!