是否可以在Chrome中创建ClipboardEvent的实例? [英] Is it possible to create instance of ClipboardEvent in Chrome?

查看:628
本文介绍了是否可以在Chrome中创建ClipboardEvent的实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以编程方式在Chrome中创建一个ClipboardEvent实例。



但是当我运行构造函数时:

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

它会抛出以下错误:

 未捕获的TypeError:非法的构造函数

构造函数在Firefox中按照预期工作。



选中 MDN W3C规范,并且他们没有提及创建ClipboardEvent实例是非法的。



是否有可能以任何其他方式在Chrome中创建ClipboardEvent的实例?我更喜欢在存在自定义ClipboardEvent时模拟它。

解决方案不幸的是,事实并非如此。这是来自 http://caniuse.com/#feat=clipboard


IE中的部分支持是指使用与剪贴板交互的非标准方法。对于其他浏览器,它指的是不支持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

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.

这篇关于是否可以在Chrome中创建ClipboardEvent的实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆