异步剪贴板 API
异步剪贴板 API — navigator.clipboard 提供 read()/write()(以及仅处理文本的
readText()/writeText()),使页面能够以编程方式复制和粘贴,而不必依赖较旧的
document.execCommand('copy')。访问受到限制:大多数引擎要求调用发生在用户手势事件
处理程序内,或者已获得 clipboard-read/clipboard-write 权限。
浏览器与生态支持
Section titled “浏览器与生态支持”| Browser / Platform | Support | Since | Confidence | Source | Notes |
|---|---|---|---|---|---|
| Chrome (Desktop) | ✅ yes | 76 | high | ref | read() requires the clipboard-read permission. write() requires the clipboard-write permission or, from Chrome 107, a user gesture. |
| Edge (Desktop) | ✅ yes | 79 | high | ref | — |
| Firefox (Desktop) | ✅ yes | 127 | high | ref | write()/read() must be called within a user gesture event handler. |
| Safari (macOS) | ✅ yes | 13.1 | high | ref | — |
← 返回兼容性浏览器。