• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

15. Dynamic Content Applications > 15.3. Automating the Search-and-Replace of B...

Automating the Search-and-Replace of Body Content

NN n/a, IE 4(Win)

Problem

You want to offer a search-and-replace function for body content.

Solution

This recipe works only in Internet Explorer 4 or later for Windows because of its heavy dependence upon the TextRange object (not implemented in IE/Mac through Version 5.x). On the plus side, it also works with textarea element content.

Use the rangeReplace.js library (Example 15-1 in the Discussion) to automate search and replace operations with the IE TextRange object. You have your choice of two functions, depending on the type of search-and-replace user experience you prefer. Invoke the srBatch( ) function for unprompted batch replacement:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint