CD-440 Part VI . Appendixes Example You can (Unable to start debugging on the web server)

CD-440 Part VI . Appendixes Example You can find examples of the expand()method in Listing 15-14. findText( searchString [,searchScope,flags]) NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility Example Listing 19-11 implements two varieties of text search and replace operation, while showing you how to include extra parameters for case-sensitive and whole word searches. Both approaches begin by creating a TextRangefor the entire body, but they immediately shift the starting point to the beginning of the DIV element that contains the text to search. One search and replace function prompts the user to accept or decline replacement for each instance of a found string. The select() and scrollIntoView() methods are invoked to help the user see what is about to be replaced. Notice that even when the user declines to accept the replacement, the text range is collapsed to the end of the found range so that the next search can begin after the previously found text. Without the collapse() method, the search can get caught in an infinite loop as it keeps finding the same text over and over (with no replacement made). Because no counting is required, this search and replace operation is implemented inside a while repeat loop. The other search and replace function goes ahead and replaces every match and then displays the number of replacements made. After the loop exits (because there are no more matches), the loop counter is used to display the number of replacements made. Listing 19-11: Two Search and Replace Approaches (with Undo) TextRange.findText() Method