You are here: Reference > JavaScript > client-side > event handling > events > onselectstart

onselectstart event | selectstart event

Browser support:
Occurs at the start of a selection process.
The onselectstart event is cancelable, if you cancel it, the selection process does not start.
For a cross-browser solution, if you want to disable the selection for an element or for the entire document, use the unselectable property in Internet Explorer and Opera and the MozUserSelect and webkitUserSelect style properties in Firefox, Google Chrome and Safari.

How to register:

In HTML:
<ELEMENT onselectstart="handler">

In JavaScript:
object.onselectstart = handler;
object.addEventListener ("selectstart", handler, useCapture);
9
object.attachEvent ("onselectstart", handler);
You can find the related objects in the Supported by objects section below.
The event object is accessible to all event handlers in all browsers. The properties of the event object contain additional information about the current event. To get further details about these properties and the possible event handler registration methods, please see the page for the event object.
For a complete list of events, see the page for Events in JavaScript.

Basic information:

Bubbles Yes
Cancelable Yes
Event object Event

Actions that invoke the onselectstart event:

  • Starting to select some content.
  • In Internet Explorer, changing the selection by script (through the selection object or with the select method).

The order of events related to the onselectstart event:

  1. onselectstart
  2. onselect
  3. onselectionchange

Example HTML code 1:

This example illustrates the use of the onselectstart event:
<div>The selection process can start in this text.</div>
<br />
<div onselectstart="return false">The selection process cannot start in this text.</div>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content