cut, copy, paste

Test page.

Events overview page.

The cut, copy, and paste events fire when the user cuts, copies or pastes a text or image.

Event IE 5.5 IE 6 IE 7 IE8rc1 as IE7 IE8rc1 as IE8 FF 2.0 FF 3.0 FF 3.1b2 Saf 3.0 Win Saf 3.1 Win iPhone 3G Chrome 1.0 Opera 9.62 Opera 10a Konqueror 3.5.7
On the window
No No Buggy No Incomplete Untestable Incomplete No No
  • See below for Firefox 3.
  • Safari 3.1 and Crhome fire the events on the window only when you use addEventListener.
On the document
No No Buggy Yes Untestable Yes No No
  • See below for Firefox 3.
On forms
Yes No Buggy Yes Untestable Yes No No
  • See below for Firefox 3.
On text inputs
Yes No Buggy Yes Untestable Yes No No
  • See below for Firefox 3.
Event IE 5.5 IE 6 IE 7 IE8rc1 as IE7 IE8rc1 as IE8 FF 2.0 FF 3.0 FF 3.1b2 Saf 3.0 Win Saf 3.1 Win iPhone 3G Chrome 1.0 Opera 9.62 Opera 10a Konqueror 3.5.7
On images

When you go to the context menu and select 'Copy image' or a similar command.

Yes No No Untestable No No No
On any element

In general only the copy event should be available, since it's not possible to cut or paste text from or to, say, a paragraph.

Yes No Buggy Yes Untestable Yes No No
  • See below for Firefox 3.
Prevent default

The point of these events: can you prevent a cut, copy or paste action from taking place?

Yes Untestable Yes Almost Untestable Almost Untestable Untestable
  • In Safari and Chrome the default of the copy event can be prevented, but the clipboard is emptied, while it should retain the previous value, as it does in IE and Firefox.
Event bubbling

These events should bubble up.

Yes Untestable Yes Yes Untestable Yes Untestable Untestable
Cancel bubble
Yes Untestable Yes Yes Untestable Yes Untestable Untestable
Event IE 5.5 IE 6 IE 7 IE8rc1 as IE7 IE8rc1 as IE8 FF 2.0 FF 3.0 FF 3.1b2 Saf 3.0 Win Saf 3.1 Win iPhone 3G Chrome 1.0 Opera 9.62 Opera 10a Konqueror 3.5.7

Firefox bug

Firefox 3 has a lazy implementation: it fires these events whenever the user presses the Cut, Copy, or Paste shortcut keys, whether that action makes sense in a given context or not.

For instance, when you press [Ctrl | Cmd]+X while the focus is nowhere in particular and you have not selected any text, Firefox will fire a cut event, even though there's nothing to cut.

IE and Safari check if something is actually cut, copied or pasted before firing the events.

Related events

Event IE 5.5 IE 6 IE 7 IE8rc1 as IE7 IE8rc1 as IE8 FF 2.0 FF 3.0 FF 3.1b2 Saf 3.0 Win Saf 3.1 Win iPhone 3G Chrome 1.0 Opera 9.62 Opera 10a Konqueror 3.5.7
beforecopy

Test page.

Yes No No Yes Untestable Yes No No

I do not understand the real purpose of these events. However, when the user calls up a context menu that contains cut, copy and paste actions, beforecut, beforecopy and beforepaste all fire.

beforecut

Test page.

Yes No No Yes Untestable Yes No No

See beforecopy.

beforepaste

Test page.

Yes No No Incomplete Untestable Incomplete No No

See beforecopy.

  • Safari 3.1 and Chrome do not fire this event before an actual paste action. It works fine on context menus.
Event IE 5.5 IE 6 IE 7 IE8rc1 as IE7 IE8rc1 as IE8 FF 2.0 FF 3.0 FF 3.1b2 Saf 3.0 Win Saf 3.1 Win iPhone 3G Chrome 1.0 Opera 9.62 Opera 10a Konqueror 3.5.7

These compatibility tables are sponsored by

Google