onselect attribute is used in forms, specifically
on the text
textarea form controls. When the user
selects any text inside these elements, either by clicking and dragging
the cursor, or using keyboard text selection commands (such as pressing
Shift + Right arrow key), the
captures this event.
attribute might be used when the users have submitted a
form and are presented with something that
they then need to copy in order to use—for example, some code to paste
into their web page. The form control (
textarea) could use the
automatically copy the text and notify the user that it was saved to the
clipboard, ready for them to paste:
<textarea rows="10" name="generatedCode" onselect="copyToClipBoard();">Text content inside the textarea</textarea>
This attribute has no fixed value.
It’s up to the author to decide on the scripting that’s included here, be
that a call to one or more defined functions, or a simple
Every browser listed supports this attribute. However, inline event handlers such as this should be avoided. In the same way that inline CSS styles are frowned upon but externally defined CSS styles are considered good practice, inline event handlers should be stripped out and replaced with events attached unobtrusively through the DOM.
There are no comments yet.