faqts : Computers : Programming : Languages : JavaScript : Forms : TextAreas/TextFields

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 12 people (67%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How do I get the highlight value from a TextArea or TextFields for both Netscape and IE?

Dec 15th, 2001 07:04
John F, Nigil Chua, http://www.faqts.com/knowledge_base/view.phtml/aid/3194/fid/130


Can't be done for Netscape. See the referenced answer.

For IE, try:

var myRange = document.selection.createRange();

myRange can then be manipulated (you might especially want to use
its "text" and "htmlText" attributes):

myRange.text = 'blah ' + myRange.htmlText + ' blah';