October 23, 2001 - Detecting a Selection
October 23, 2001|
Detecting a Selection
Tips: October 2001
Yehuda Shiran, Ph.D.
document.selectionobject which encapsulates a property and several methods that handle selections. The selection object provides information about the text and elements the user has currently highlighted with the mouse. This can be very useful if you want to perform some action based upon what the user has selected.
The selection object's type property defines the type of selection. This read-only string property can have one of the following values:
No selection or insertion point.
The selection is a text selection.
The selection is a control selection.
"None", when there is no selection. Therefore, comparing the value of
"None" on Internet Explorer 4.0x and up, is equivalent to comparing the value returned by the
""on Navigator 4.0x and Netscape 6.
Play around and select some lines. Press here to see the selection type.