select

Test page.

Events overview page.

The select event fires when the user selects text in a text input. It should also fire when the user selects text elsewhere.

But when does this event fire?

  1. IE fires the event once for every character that's added to the selection, whether the user uses the mouse or the keyboard.
  2. All other browsers fire the event when a mouseup occurs after the user has selected text.
  3. All other browsers fire the event when a keyup occurs after the user has selected text.
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 Yes Yes Untestable Yes Minimal No

Is this event available on the window?

  • Opera allows registration on the window only when you use attachEvent.
On the document
No Yes Yes Untestable Yes Yes No

Is this event available on the document?

On a form
No Yes Yes Untestable Yes Yes No

Is this event available on a form?

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 text inputs
Yes Yes Yes Untestable Yes Yes No

The point of this event.

On any element
No No No Untestable No No No

It stands to reason that selecting text on any element (such as a paragraph) should also fire the event. When that happens, pass the resulting Range object as a property of the event object, please.

Browsers universally disagree with this idea.

Event bubbling

The event should bubble.

Untestable Yes Yes Untestable Yes Almost Untestable
  • When using attachEvent registration, Opera fires the event on the window before the event on the document. (The event isn’t available on the window in any other registration.) An event on the window is equal to an event on the <body> in order to support ancient inline event handlers such as <body onload="something()>.
Prevent default
“No” is the correct answer
No No No Untestable No No Untestable

The default action cannot be prevented.

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