onselectionchange event | selectionchange event
Occurs when the selection in the document has changed.
To get the current selection within the document, use the selection object in Internet Explorer.
How to register:
In HTML:
In JavaScript:
This event cannot be registered in HTML.
In JavaScript:
object.onselectionchange = handler; | |||||||||||
object.addEventListener ("selectionchange", handler, useCapture); |
| ||||||||||
object.attachEvent ("onselectionchange", 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 | No |
Cancelable | No |
Event object | Event |
Actions that invoke the onselectionchange event:
The order of events related to the onselectionchange event:
- onselectstart
- onselect
- onselectionchange
Example HTML code 1:
This example illustrates the use of the onselectionchange event:
|
||||
<head> <script type="text/javascript"> document.onselectionchange = OnChange; function OnChange () { var range = document.selection.createRange (); if (range.text.length == 0) { alert ("The current selection is empty"); } else { alert ("The contents of the current selection are\n" + range.text); } } </script> </head> <body> Select this text on this page! </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments