October 21, 2001 - Detecting a Selection
October 21, 2001|
Detecting a Selection
Tips: October 2001
Yehuda Shiran, Ph.D.
Here is how the form above is defined:
<FORM> Enter your text and select it: <INPUT TYPE="text" NAME="data" SIZE="30" onSelect="alert('text selected')"> </FORM>
onselectevent handler is also supported by Internet Explorer as an event handler of
textareafields. This event does not bubble like most other events in Internet Explorer. Events that do not bubble can only be handled on the individual object that fired the event, so you cannot capture
selectevents at the document level. Try the above selection exercise in both Netscape 6 (or Navigator 4.x) and Internet Explorer. You can observe a noticeable difference. Netscape 6 (as well as Navigator 4.x) reacts to the event's completion, when the mouse button is being released. Internet Explorer, though, reacts to the event's initiation, when the mouse button is being pressed. See Column 10 (The Internet Explorer Event Model) for a complete discussion of the Internet Explorer event model, and Column 11 (The Cross Browser Event Model) for the cross-browser event model.