Visit Mozilla.org

DOM:range

MDC

« Gecko DOM Reference

Range 객체는 주어진 document 내의 텍스트 노드들의 부분들(parts)과 document의 단편화에 포함된 노드들을 나타내고 있습니다.

Range 오브젝트는 Document 객체에 포함되어 있는 createRange 메소드를 사용하여 생성할 수 있습니다. 또한 selection 객체에 포함되어 있는 getRangeAt 메소드를 사용하여 추출할 수 있습니다.

목차

[편집] 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.

[편집] Methods

[편집] 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.

[편집] 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.

[편집] 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

[편집] Gecko Methods

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

compareNode 안씀
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 안씀
Returns a boolean indicating whether the given node intersects the range.
isPointInRange
Returns a boolean indicating whether the given point is in the range.