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.

300<br />

<strong>JavaScript</strong> <strong>Examples</strong> <strong>Bible</strong>: The Essential Companion to <strong>JavaScript</strong> <strong>Bible</strong><br />

If you want to experiment by finding other chunks of text and looking at both the<br />

text and htmlText properties, first restore the text range to encompass the entire<br />

body with the following statement:<br />

a.expand(“textEdit”)<br />

You can read about the expand() method later in this chapter. In other tests, use<br />

findText() to set the range to “for all” and just “for al.” Then, see how the<br />

htmlText property exposes the EM element’s tags.<br />

text<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓<br />

Example<br />

See Listing 19-11 later in this chapter for the findText() method to see the<br />

text property used to perform the replace action of a search-and-replace function.<br />

Methods<br />

collapse([startBoolean])<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓<br />

Example<br />

See Listings 19-11 (in this chapter) and 15-14 (in Chapter 1 of this book) to see<br />

the collapse() method at work.<br />

compareEndPoints(“type”, rangeRef)<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓<br />

Example<br />

The page rendered by Listing 19-10 lets you experiment with text range comparisons.<br />

The bottom paragraph contains a SPAN element that has a TextRange<br />

object assigned to its text after the page loads (in the init() function). That fixed<br />

range becomes a solid reference point for you to use while you select text in the<br />

TextRange.compareEndPoints()

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

Saved successfully!

Ooh no, something went wrong!