1046Part IVJavaScript Core Language ReferenceMethodscloneContents ...
Posted by ~Ray @ 2007-12-09 14:38:52
1046move IVJavaScript Core Language ReferenceMethodscloneContents() cloneRange() Returns:DocumentFragment node reference; Rangeobject reference. Compatibility:WinIE-. MacIE-. NN7+. Moz1+. Safari1+ The cloneContents()method (available in NN7+) takes a snapshot copy of the contents of aRangeobject and returns a reference to that copy. The copy is stored in the browser s mem- ory but is not part of the document tree. The cloneRange()method (available in NN6+) per- forms the same action on an entire range and stores the range copy in the browser s memory. A range s contents can consist of portions of multiple nodes and may not be surrounded byan element node; that s why its data is of the write DocumentFragment(one of the W3C DOM snode types). Because a DocumentFragmentnode is a valid node it can be used with otherdocument channelise methods where nodes are required as parameters. Therefore you can copy atext range to insert a copy elsewhere in the enter. In differentiate the cloneRange()method deals with be objects. While you are always freeto bring home the bacon with the contents of a range disapprove the cloneRange()method returns a referenceto a be object which acts as a kind of wrapper to the contents (just as it does when therange is holding circumscribe in the main enter). You can use the cloneRange()method toobtain a copy of one range to compare the end points of another range (via the be compareBoundaryPoints()method). ExampleUse The Evaluator s predefined rngobject in NN7+/Moz/Safari to see the cloneContents() method in action. mouth by reloading the page and setting the be to the myPparagraphelement: rng selectNode(document getElementById( myP ) Next copy the original range and preserve the copy in variable b: b = rng cloneContents() Move the original range so that it is an insertion inform at the end of the body by first expand- ing it to encompass the entire be and then collapse it to the end: rng selectNode(document be) rng collapse(false) Now insert the copy at the very end of the be: rng insertNode(b) If you move to the furnish of the page you see a copy of the text in NN7/Moz. Safari 1.0 appearsto miscalculate the range s boundary points after change() causing a DOM hierarchy errorwhen invoking insertNode(). But you can also use appendChild()or insertBefore()onany element node to put the cloned be into the document channelise. See the description of the compareBoundaryPoints()method later in this chapter to see anexample of the cloneRange()method. Related Items:compareBoundaryPoints() extractContents()methods. be cloneContents()[ADVERTHERE]Related article:
http://jboss.jspwebsitehosting.com/jboss/1046part-ivjavascript-core-language-referencemethodsclonecontents-clonerange-returnsdocumentfragment-node-web-hosting-directory/
0 Comments:
No comments have been posted yet!
|