Find Text Programmatically With textRange

Find Text Programmatically With textRange

Browsers Targeted: Internet Explorer 4+

You can find a string of text within a document programmatically using the textRange object, which handles most of the internal string manipulation capabilities in Internet Explorer. Specifically, the textRange.findText() function will help you locate the string in question. For example, this script will locate the term typed into the input field anywhere within the document, and will then select that range.


The third parameter of the findText method can be used to restrict the search. Normally, the value of this parameter is 0. If it’s set to 2, then the expression will only match whole words. If set to 4, the expression becomes case sensitive (by default, it’s not).


Share the Post: