spacer
Yehuda Shiran October 23, 2001
Detecting a Selection
Tips: October 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Internet Explorer 4.0x and above features the document.selection object 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:

ValueDescription
"None"No selection or insertion point.
"Text"The selection is a text selection.
"Control"The selection is a control selection.

The default value is obviously "None", when there is no selection. Therefore, comparing the value of document.selection.type with "None" on Internet Explorer 4.0x and up, is equivalent to comparing the value returned by the document.getSelection() method with "" on Navigator 4.0x and Netscape 6.

Play around and select some lines. Press here to see the selection type.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business