onCopy clipboardData support

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

Some of the current browsers support a clipboardData property as part of a copy event. This should allow you to set the clipboard data or append custom data as a user copies an object. The support is patchy and mostly incomplete. The IE interface is older than the rest, but has had support for a while where as Chrome and Safari support has only recently been added. With IE you can only set two fixed data types Text or URL.

When parts of this paragraph of text are copied an event should fire that alters the copied test. When pasted into the box below you should see a custom message. It will currently only work with IE Chrome and Safari. Try it out by copying and pasting this paragraph into the input box below.

Paste content here, replacing this text

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