If you have selected a piece to text, in Netscape this method will return the raw unformatted text within the selection. If there are any HTML tags in the selection, they will be stripped out.
The MSIE browser employs a completely different technique that involves Selection objects and TextRange objects as a means of access to the selected text.
As it is easy to deselect the highlighted text by clicking on some other active object in the page, you will need to access the selection inside an event handler that is triggered by the selection action itself. This might be done quite effectively in an onSelectStart handler.
See also: | Document object, Document.selection, Selection object |
Prev | Home | Next |
Document.getElementsByTagName() | Up | Document.handleEvent() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |