onPaste clipboardData support

  • Not supported in Firefox
  • Supported in Chrome
  • Supported in Safari
  • Supported in IE
  • Not supported in Opera

Some of the current browsers support a clipboardData property as part of a paste event. This should allow you to query the different data formats created from the current data on the clipboard. Safari and Chrome have the best support, but it is still incomplete. Firefox has no support if you discount using the XPCOM objects interface. The IE interface is older and only supports Text or URL data.

Firefox, Safari IE and Chrome all sanitise any HTML being pasted. Opera will only paste plain text so HTML sanitisation is not an issue. Some earlier version of IE could cause some security issues as they copy hyperlinks in full. Try copying and pasting this paragraph and link into the box below.

Paste content here (contentEditable div)

Log:

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.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

Object, method, and property compatibility -

  Firefox 4.0 Chrome 10.0 Safari 5.0 IE 9.0 Opera 11.1
paste event Yes Yes Yes Yes No
clipboardData No Yes Yes Yes No
clipboardData.types No No Incomplete No No
clipboardData.getData No Incomplete Incomplete Yes No
clipboardData.setData No Incomplete Incomplete Yes No
mime types No Incomplete Incomplete No No
custom types No Incomplete Incomplete Yes No
event.clipboardData No Yes Yes No No
window.clipboardData No No No Yes No

Notes

Only Chrome and Safari support 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 the clipboardData.types arrays in both browsers contains some mine types it is not a complete list.

Useful Links

Tweet Share Share