↑
Main Page
How practical are ranges
How practical are ranges?
The dissimilarities between the DOM and IE range implementations make it difficult to create cross-
browser solutions, which is perhaps why many developers shy away from using ranges at all. When
evaluating your own usage, it’s important to understand your target audience, what browsers they will
be using, and if there is a nonrange way to create the same effect.
Ranges can provide very useful functionality on Web pages. Some pages use ranges to highlight certain
words on a page based on a series of search terms, so the user can easily find the words he or she is
searching for. Another use, popular among advertisers, is to turn certain words into links (for instance,
turning the word
computer
into a link to a computer manufacturer or the word
JavaScript
to a description
of the language).
Summary
This chapter introduced several new ways to manipulate a document’s DOM tree.
First, you learned how to affect the CSS style of elements on a Web page. Several examples were dis-
cussed, including hover effects and custom tooltips. You learned how to access the style definitions of
elements as well as CSS rules, and in doing so, saw their difference from computed styles.
The next section introduced
innerText
,
innerHTML
,
outerText
, and
outerHTML
. You learned how
innerText
can be used to change the text content of a DOM element and how
innerHTML
can be used
to change the HTML content of a DOM element. Likewise, you learned how
outerText
and
outerHTML
can be used to replace a DOM element altogether (either with plain text or HTML code, respectively).
Lastly, you learned about ranges. The differences between DOM ranges and ranges in Internet Explorer
were discussed, and several examples were given to show the similarities between the two.
333
Advanced DOM Techniques
13_579088 ch10.qxd 3/28/05 11:39 AM Page 333
Free JavaScript Editor
Ajax Editor
©
→