toString
Returns the text of the Range.
Syntax
Parameters
text is the text contained in range.
Example
range = document.createRange(); range.selectNode( document.getElementsByTagName("div").item(0)); text = range.toString();
Notes
Alerting the contents of a Range makes an implicit toString() call, so comparing range and text through an alert dialog is ineffective
Specification
Gecko Range Interface Extensions
This section describes Range methods that are particular to Mozilla and not part of the W3 DOM specifications.
Methods
compareNode
Returns a constant (see notes)
Syntax
Paramaters
Example
range = document.createRange(); range.selectNode(document.getElementsByTagName("div").item(0)); returnValue = range.compareNode(document.getElementsByTagName("p").item(0));
Notes
Specification
This method is not part of specification.
comparePoint
Syntax
Parameters
Example
Notes
If the referenceNode is a Node of type Text, Comment, or CDATASection, then offset is the number of characters from the start of referenceNode. For other Node types, offset is the number of child nodes between the start of the referenceNode.
Specification
This method is not part of a specification.
createContextualFragment
Syntax
documentFragment = range.createContextualFragment( tagString )
Parameters
tagString is text that contains text and tags to be converted to a document fragment
Example
tagString = "<div>I am a div node</div>";
range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
documentFragment = range.createContextualFragment(tagString);
document.body.appendChild(documentFragment);
Notes
This method takes a string and uses mozilla's parser to convert it to a DOM tree.
Specification
This method is not part of a specification.
intersectsNode
Returns a boolean indicating whether the given point intersects the range.
Syntax
Parameters
bool is true if the referenceNode intersects the Range, false if not.
referenceNode is the Node to compare with the Range.
Example
range = document.createRange(); range.selectNode(document. getElementsByTagName("div").item(0)); bool = range.intersectsNode(document. getElementsByTagName("p").item(0),1);
Notes
Specification
This method is not part of a specification.
isPointInRange
Returns a boolean indicating whether the given point is in the range.
Syntax
Parameters
bool is true if the referenceNode intersects the Range, false if not.
referenceNode is the Node to compare with the Range.
Example
Notes
Specification
Netscape Communications http://developer.netscape.com |