TOC PREV NEXT INDEX

domref



toString


Returns the text of the Range.

Syntax

text = range.toString();
 

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

toString

Gecko Range Interface Extensions


This section describes Range methods that are particular to Mozilla and not part of the W3 DOM specifications.

Methods

Returns a constant.
Returns -1, 0, or 1.
Returns a document fragment.
Returns a boolean indicating whether the given point intersects the range.
Returns a boolean indicating whether the given point is in the range.

compareNode


Returns a constant (see notes)

Syntax

returnValue = range.compareNode( referenceNode );
 

Paramaters

Example

range = document.createRange();
 
range.selectNode(document.getElementsByTagName("div").item(0));
 
returnValue = range.compareNode(document.getElementsByTagName("p").item(0));
 

Notes

NODE_BEFORE = 0
Node starts before the Range
NODE_AFTER = 1
Node starts after the Range
NODE_BEFORE_AND_AFTER = 2
Node starts before and ends after the Range
NODE_INSIDE = 3
Node starts after and ends before the Range, i.e. the Node is completely selected by the Range.

Specification

This method is not part of specification.

comparePoint


comparePoint()

Returns -1, 0, or 1

Syntax

returnValue = range.comparePoint( referenceNode, offset )
 

Parameters

returnValue
-1, 0, or 1 depending on whether the referenceNode is before, the same as, or after the range.
referenceNode
The Node to compare with the Range.
offset
An integer greater than or equal to zero representing the offset inside the referenceNode.

Example

range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
returnValue = range.comparePoint(document.getElementsByTagName("p").item(0),1);

 

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


Returns a document fragment

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

bool = range.intersectsNode( referenceNode )
 

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

None

Specification

This method is not part of a specification.

isPointInRange


Returns a boolean indicating whether the given point is in the range.

Syntax

bool = range.intersectsNode( referenceNode )
 

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

None

Specification

This method is not part of a specification.


Netscape Communications
http://developer.netscape.com
TOC PREV NEXT INDEX