此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

ClipboardEvent()

基线 广泛可用

自 2018年4月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

ClipboardEvent() 构造函数返回一个新建的 ClipboardEvent 对象,这个对象表示与修改剪切板相关的事件,这些事件包括 cutcopypaste 事件。

语法

js
new ClipboardEvent(type)
new ClipboardEvent(type, options)

参数

ClipboardEvent() 构造函数也从 Event() 继承参数。

type

一个 String 字符串,描述了 ClipboardEvent 事件类型的名字,大小写敏感,可以是:'copy''cut'或者 'paste'

options 可选

选项如下:

  • clipboardData: 一个 DataTransfer containing the data concerned by the clipboard event.
  • dataType: A String containing the MIME-type of the data contained in the data argument.
  • data: A String containing the data concerned by the clipboard event.

规范

规范
Clipboard API and events
# dom-clipboardevent-clipboardevent

浏览器兼容性

参见