草案
此页面不完整。

只读 类型 特性为 ClipboardItem interface returns an 数组 of MIME 类型 available within the ClipboardItem

句法

var types = clipboardItem.types;
					

数组 of available MIME 类型 .

范例

In the below example, we're returning all items on the clipboard via the clipboard.read() method. Then checking the 类型 property for available types before utilizing the ClipboardItem.getType() method to return the Blob object. If no clipboards contents is found for the specified type, an error is returned.

async function getClipboardContents() {
  try {
    const clipboardItems = await navigator.clipboard.read();
    for (const clipboardItem of clipboardItems) {
      for (const type of clipboardItem.types) {
        const blob = await clipboardItem.getType(type);
        // we can now use blob here
      }
    }
  } catch (err) {
    console.error(err.name, err.message);
  }
}
					

规范

规范 状态 注释
Clipboard API and events
The definition of 'ClipboardItem' in that specification.
工作草案 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
类型 Chrome 66 Edge ≤79 Firefox No IE No Opera Yes Safari No WebView Android 66 Chrome Android 66 Firefox Android No Opera Android Yes Safari iOS No Samsung Internet Android Yes

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

另请参阅

元数据

  • 最后修改: