JavaScript Reference

Local Navigation

Range API

Object

Description

Availability

Range

Represents a range of content between two boundary points, a start point and an end point, in a Document, DocumentFragment, or Attr node.

4.7.1 or later

Object: Range

Availability

BlackBerry Device Software version 4.7.1 or later

The Range object represents a range of content between two boundary points, a start point and an end point, in a Document, DocumentFragment, or Attr node.

You can create a Range object by using Document.createRange. You can retrieve a Range object by using Selection.getRangeAt.

Back To Top

Range properties

Property name

Type

Description

Status

Support level

Availability

collapsed

boolean

Returns true if the start point and end point of the range are the same.

read-only

DOM 2 Range

4.7.1 or later

commonAncestorContainer

Node

Returns the deepest node that contains the startContainer and endContainer nodes.

read-only

DOM 2 Range

4.7.1 or later

endContainer

Node

Returns the node that contains the end point of the range.

read-only

DOM 2 Range

4.7.1 or later

endOffset

int

Returns a number that represents the end point of the range within the endContainer node.

read-only

DOM 2 Range

4.7.1 or later

startContainer

Node

Returns the node that contains the start point of the range.

read-only

DOM 2 Range

4.7.1 or later

startOffset

int

Returns a number that represents the start point of the range within the startContainer node.

read-only

DOM 2 Range

4.7.1 or later

Back To Top

Range methods

Method name

Description

Support level

Availability

cloneContents()

Duplicates the contents of a specified range.

DOM 2 Range

4.7.1 or later

cloneRange()

Creates a new Range object with the same start point and end point as the specified range.

DOM 2 Range

4.7.1 or later

collapse()

Collapses a range onto its start point or end point.

DOM 2 Range

4.7.1 or later

compareBoundaryPoints()

Compares the start points and end points of two ranges.

DOM 2 Range

4.7.1 or later

deleteContents()

Deletes the contents of the range from the Document or DocumentFragment node.

DOM 2 Range

4.7.1 or later

detach()

Immediately releases the Range object from the object model.

DOM 2 Range

4.7.1 or later

extractContents()

Extracts the entire contents of the range from a Document or DocumentFragment node and moves it to a new DocumentFragment object.

DOM 2 Range

4.7.1 or later

insertNode()

Inserts a new node at the start of the range.

DOM 2 Range

4.7.1 or later

selectNode()

Populates the range with a specified node and its contents.

DOM 2 Range

4.7.1 or later

selectNodeContents()

Populates the range with the contents of a specified node.

DOM 2 Range

4.7.1 or later

setEnd()

Sets the end point of the range.

DOM 2 Range

4.7.1 or later

setEndAfter()

Sets the end point of a range at a position that is after the specified node.

DOM 2 Range

4.7.1 or later

setEndBefore()

Sets the end point of a range at a position that is before the specified node.

DOM 2 Range

4.7.1 or later

setStart()

Sets the start point of the range.

DOM 2 Range

4.7.1 or later

setStartAfter()

Sets the start point of a range at a position that is after the specified node.

DOM 2 Range

4.7.1 or later

setStartBefore()

Sets the start point of a range at a position that is before the specified node.

DOM 2 Range

4.7.1 or later

surroundContents()

Moves the contents of the range to a new node object, and inserts the new node at the start point of the range.

DOM 2 Range

4.7.1 or later

toString()

Returns the contents of the range as a string.

DOM 2 Range

4.7.1 or later

Back To Top
Next topic: Storage API
Previous topic: ApplicationCache methods

Was this information helpful? Send us your comments.