- Not supported in Firefox
- Supported in Chrome
- Not supported in Safari
- Not supported in IE
- Not supported in Opera
Some of the current browsers support a clipboardData property as part of the copy and paste event. This should allow you to query the different data formats currently on the clipboard using mimetypes. The support is still incomplete across most browsers, but Chrome has recently added new support for copy and paste.
This demo copies a contact, passing the information as a vCard using the mimetype text/x-vcard. Try it out - in Chrome click on the contact below to select it and then copy it, either through the context menu or by Ctrl+C. Then paste the vCard into the paste page using only the keyboard shortcut ie Ctrl+V
Object, method, and property compatibility
Firefox 14.0.1 | Chrome 22.0 | Safari 6.0 | IE 9.0 | Opera 12.01 | |
paste event | Yes | Yes | Yes | Yes | No |
paste event on non-editable element | No | Yes | No | No | No |
clipboardData | No | Yes | Yes | Yes | No |
clipboardData.types | No | Yes | Yes | No | No |
clipboardData.items | No | Yes | No | No | No |
clipboardData.getData | No | Yes | Yes | Yes | No |
clipboardData.setData | No | Yes | Yes | Yes | No |
mime types | No | Yes | Yes | No | No |
custom types | No | Yes | Yes | Yes | No |
event.clipboardData | No | Yes | Yes | No | No |
window.clipboardData | No | No | No | Yes | No |
Notes
Only Chrome and Safari supports the clipboardData.types array which should list all the supported data formats for a given clipboard item. A copied piece of HTML could be represented as text/plain, text/html and text/url-list. Although Safari's clipboardData.types contains some mine types it is not a complete list. Safari seems currently unable to set custom data during the copy event using the clipboardData.setData method.