GlobalEventHandlers.onselect
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Обработчик события select окна браузера.
Синтаксис
window.onselect = funcRef;
funcRef
- функция
Пример
html
<html>
<head>
<title>onselect test</title>
<style type="text/css">
.text1 {
border: 2px solid red;
}
</style>
<script type="text/javascript">
window.onselect = selectText;
function selectText() {
alert("select event detected!");
}
</script>
</head>
<body>
<textarea class="text1" cols="30" rows="3">
Highlight some of this text
with the mouse pointer
to fire the onselect event.
</textarea
>
</body>
</html>
Замечание
Событие select происходит только, когда текст выделяют в поле input с type='text' или в поле textarea. Событие происходит только после того, как текст будет выделен.
Спецификации
Specification |
---|
HTML # event-select |
HTML # handler-onselect |
Совместимость с браузерами
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
select event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.