15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5 ✦ Body Text Objects (Chapter 19)<br />

// perform the undo<br />

function undoReplace() {<br />

if (newRanges.length && origSearchString) {<br />

for (var i = 0; i < newRanges.length; i++) {<br />

rng.moveToBookmark(newRanges[i])<br />

rng.text = origSearchString<br />

}<br />

document.all.counter.innerText = i<br />

clearUndoBuffer()<br />

}<br />

}<br />

<br />

<br />

<br />

TextRange.findText() Method<br />

<br />

<br />

Enter a string to search for in the following text:<br />

&nbsp;<br />

Case-sensitive &nbsp;<br />

Whole words only<br />

Enter a string with which to replace found text:<br />

<br />

<br />

<br />

0 items found and replaced.<br />

<br />

<br />

<br />

<br />

ARTICLE I<br />

<br />

<br />

Congress shall make no law respecting an establishment of religion, or<br />

prohibiting the free exercise thereof; or abridging the freedom of speech, or of<br />

the press; or the right of the people peaceably to assemble, and to petition the<br />

government for a redress of grievances.<br />

<br />

[The rest of the text is snipped for printing here, but it is on the CD-ROM<br />

version.]<br />

<br />

<br />

<br />

Having a search-and-replace function available in a document is only one-half of<br />

the battle. The other half is offering the facilities to undo the changes. To that end,<br />

307<br />

TextRange.findText()

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!