Node: selectstart event
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The selectstart event of the Selection API is fired when a user starts a new selection.
If the event is canceled, the selection is not changed.
Syntax
Use the event name in addEventListener():
js
addEventListener("selectstart", (event) => { })
Alternatively, assign to the event handler property of the interface:
js
onselectstart = (event) => { }
Event type
A generic Event.
Examples
js
// addEventListener version
document.addEventListener("selectstart", () => {
console.log("Selection started");
});
// onselectstart version (but note that this replaces other event listeners
// added using onselectstart, if any)
document.onselectstart = () => {
console.log("Selection started.");
};
Specifications
| Specification |
|---|
| Selection API> # selectstart-event> |
| Selection API> # dom-globaleventhandlers-onselectstart> |