DOM:range
From MDC
The Range object represents a fragment of a document that can contain nodes and parts of text nodes in a given document.
A range can be created using the createRange method of the Document object. Range objects can also be retrieved by using the getRangeAt method of the selection object.
Contents |
[edit] Properties
- collapsed
- Returns a boolean indicating whether the range's start and end points are at the same position.
- commonAncestorContainer
- Returns the deepest Node that contains the startContainer and endContainer Nodes.
- endContainer
- Returns the Node within which the Range ends.
- endOffset
- Returns a number representing where in the endContainer the Range ends.
- startContainer
- Returns the Node within which the Range starts.
- startOffset
- Returns a number representing where in the startContainer the Range starts.
[edit] Methods
[edit] Positioning Methods
These methods set the start and end points of a range.
- setStart
- Sets the start position of a Range.
- setEnd
- Sets the end position of a Range.
- setStartBefore
- Sets the start position of a Range relative to another Node.
- setStartAfter
- Sets the start position of a Range relative to another Node.
- setEndBefore
- Sets the end position of a Range relative to another Node.
- setEndAfter
- Sets the end position of a Range relative to another Node.
- selectNode
- Sets the Range to contain the node and its contents.
- selectNodeContents
- Sets the Range to contain the contents of a Node.
- collapse
- Collapses the Range to one of its boundary points.
[edit] Editing Methods
These methods retrieve Nodes from a range and modify the contents of a range.
- cloneContents
- Returns a document fragment copying the nodes of a Range.
- deleteContents
- Removes the contents of a Range from the document.
- extractContents
- Moves contents of a Range from the document tree into a document fragment
- insertNode
- Insert a node at the start of a Range.
- surroundContents
- Moves content of a Range into a new node.
[edit] Other Methods
- compareBoundaryPoints
- Compares the boundary points of two Ranges.
- cloneRange
- Returns a Range object with boundary points identical to the cloned Range.
- detach
- Releases Range from use to improve performance.
- toString
- Returns the text of the Range
[edit] Gecko Methods
This section describes Range methods that are particular to Mozilla and not part of the W3C DOM specifications.
- compareNode Obsolete
- Returns a constant representing whether the node is before, after, inside, or surrounding the range.
- comparePoint
- Returns -1, 0, or 1 indicating whether the point occurs before, inside, or after the range.
- createContextualFragment
- Returns a document fragment created from a given string of code.
- intersectsNode Obsolete
- Returns a boolean indicating whether the given node intersects the range.
- isPointInRange
- Returns a boolean indicating whether the given point is in the range.