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.
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.
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("selectstart", (event) => {}); onselectstart = (event) => {};
A generic Event
.
js
// addEventListener version document.addEventListener("selectstart", () => { console.log("Selection started"); }); // onselectstart version document.onselectstart = () => { console.log("Selection started."); };
Specification |
---|
Selection API # selectstart-event |
Selection API # dom-globaleventhandlers-onselectstart |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
selectstart_event |
1 | 12 | 52 | 5 | 15 | 1.3 | 4.4 | 18 | 52 | 14 | No | 1.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Node/selectstart_event