15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

282<br />

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

}<br />

Listing 19-4 (continued)<br />

}<br />

return “comes after”<br />

break<br />

default :<br />

return “vs.”<br />

function init() {<br />

fixedRange = document.createRange()<br />

fixedRange.selectNodeContents(document.getElementById(“fixedRangeElem”).<br />

firstChild)<br />

fixedRange.setEnd(fixedRange.endContainer,<br />

fixedRange.endContainer.nodeValue.length)<br />

}<br />

<br />

<br />

<br />

TextRange.compareBoundaryPoints() Method<br />

<br />

Select text in the paragraph in various places relative to<br />

the fixed text range (shown in red). See the relations between<br />

the fixed and selected ranges with respect to their start<br />

and end points.<br />

<br />

PropertyReturned ValueFixed Range vs. Selection<br />

<br />

StartToEnd<br />

&nbsp;<br />

Start of Fixed vs.<br />

End of Selection<br />

<br />

<br />

StartToStart<br />

&nbsp;<br />

Start of Fixed vs.<br />

Start of Selection<br />

<br />

<br />

EndToStart<br />

&nbsp;<br />

End of Fixed vs.<br />

Start of Selection<br />

<br />

<br />

EndToEnd<br />

&nbsp;<br />

End of Fixed vs.<br />

End of Selection<br />

<br />

Range.compareBoundaryPoints()

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

Saved successfully!

Ooh no, something went wrong!