번역이 완료되지 않았습니다. Please help translate this article from English
Range 객체는 주어진 document 내의 텍스트 노드들의 부분들(parts)과 document의 단편화에 포함된 노드들을 나타내고 있다.
Range 오브젝트는 Document 객체에 포함되어 있는 createRange 메소드를 사용하여 생성할 수 있다. 또한 selection 객체에 포함되어 있는 getRangeAt 메소드를 사용하여 추출할 수 있다.
Range() 생성자 또한 사용 가능하다.
속성
- collapsed
- Range의 시작점과 끝점이 같인 위치인지를 알 수 있는 boolean 값을 반환한다.
- commonAncestorContainer
- startContainer와 endContainer 노드들을 포함한 최상위 노드를 반환한다.
- endContainer
- Range의 끝 위치를 포함하는 Node를 반환한다.
- endOffset
- endContainer 안에 있는 Range 끝을 나타내는 숫자(offset)를 반환한다.
- startContainer
- Range의 시작 위치를 포함하는 Node를 반환한다.
- startOffset
- startContainer 안에 있는 Range 시작을 나타내는 숫자(offset)를 반환한다.
생성자
메서드
상속한 메서드는 없다.
Range.setStart()Range 의 시작 위치를 설정한다.Range.setEnd()Range 의 끝 위치를 설정한다.Range.setStartBefore()- 다른
Node와 관계가 있는Range 의 시작 위치를 설정한다. Range.setStartAfter()- 다른
Node와 관계가 있는Range 의 시작 위치를 설정한다. Range.setEndBefore()- 다른
Node와 관계가 있는Range 의 끝 위치를 설정한다. Range.setEndAfter()- 다른
Node와 관계가 있는Range 의 끝 위치를 설정한다. Range.selectNode()Range 에Node와 그것의 내용물을 포함 시킨다.Range.selectNodeContents()Range 에Node의 내용물을 포함 시킨다.Range.collapse()Range의 경계 지점 중 하나로 영역을 붕괴 시킨다.Range.cloneContents()Range의 노드들을 복사하여DocumentFragment를 반환한다.Range.deleteContents()Document로 부터Range의 컨텐츠들을 삭제한다.Range.extractContents()Document트리로 부터Range의 컨텐츠들을 domxref("DocumentFragment") }} 로 이동시킨다.Range.insertNode()Range의 맨 앞에Node를 삽입한다.Range.surroundContents()- Moves content of a
Rangeinto a newNode. Range.compareBoundaryPoints()- Compares the boundary points of the
Rangewith anotherRange. Range.cloneRange()- Returns a
Rangeobject with boundary points identical to the clonedRange. Range.detach()- Releases the
Rangefrom use to improve performance. Range.toString()- Returns the text of the
Range. Range.compareNode()- Returns a constant representing whether the
Nodeis before, after, inside, or surrounding the range. Range.comparePoint()- Returns -1, 0, or 1 indicating whether the point occurs before, inside, or after the
Range. Range.createContextualFragment()- Returns a
DocumentFragmentcreated from a given string of code. Range.getBoundingClientRect()- Returns a
ClientRectobject which bounds the entire contents of theRange; this would be the union of all the rectangles returned byrange.getClientRects(). Range.getClientRects()- Returns a list of
ClientRectobjects that aggregates the results ofElement.getClientRects()for all the elements in theRange. Range.intersectsNode()- Returns a
booleanindicating whether the given node intersects theRange. Range.isPointInRange()- Returns a
booleanindicating whether the given point is in theRange.
명세
| Specification | Status | Comment |
|---|---|---|
| DOM The definition of 'Range' in that specification. |
Living Standard | Do not use RangeException anymore, use DOMException instead.Made the second parameter of collapse() optional.Added the methods isPointInRange(), comparePoint(), and intersectsNode().Added the constructor Range(). |
| DOM Parsing and Serialization The definition of 'Extensions to Range' in that specification. |
Working Draft | Added the method createContextualFragment(). |
| CSS Object Model (CSSOM) View Module The definition of 'Extensions to Range' in that specification. |
Working Draft | Added the methods getClientRects() and getBoundingClientRect(). |
| Document Object Model (DOM) Level 2 Traversal and Range Specification The definition of 'Range' in that specification. |
Obsolete | Initial specification. |
브라우저 호환성
Update compatibility data on GitHub
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Range | Chrome Full support Yes | Edge Full support 12 | Firefox
Full support
4
| IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android
Full support
4
| Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
Range() constructor | Chrome Full support Yes | Edge Full support ≤18 | Firefox Full support 24 | IE No support No | Opera Full support 15 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 24 | Opera Android Full support 14 | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
cloneContents | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
cloneRange | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
collapse | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
collapsed | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
commonAncestorContainer | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
compareBoundaryPoints | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
compareNode | Chrome No support No | Edge No support No | Firefox No support No | IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Firefox Android No support No | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No |
comparePoint | Chrome Full support Yes | Edge Full support 17 | Firefox Full support Yes | IE No support No | Opera Full support 15 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support 14 | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
createContextualFragment | Chrome Full support Yes | Edge Full support 12 | Firefox Full support Yes | IE Full support 11 | Opera Full support 15 | Safari Full support 9 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support 14 | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
deleteContents | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
detach | Chrome
Full support
Yes
| Edge Full support 12 | Firefox
No support
4 — 15
| IE Full support 9 | Opera Full support 9 | Safari
Full support
Yes
| WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android
No support
4 — 15
| Opera Android Full support Yes | Safari iOS
Full support
Yes
| Samsung Internet Android Full support Yes |
endContainer | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
endOffset | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
extractContents | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
getBoundingClientRect | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 15 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support 14 | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
getClientRects | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 15 | Safari Full support 5 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support 14 | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
insertNode | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support 10.1 | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
intersectsNode | Chrome Full support Yes | Edge Full support 17 | Firefox Full support 17 | IE No support No | Opera Full support 15 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 19 | Opera Android Full support 14 | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
isPointInRange | Chrome Full support Yes | Edge Full support 15 | Firefox Full support Yes | IE No support No | Opera Full support 15 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support 14 | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
selectNode | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
selectNodeContents | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
setEnd | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
setEndAfter | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
setEndBefore | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
setStart | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
setStartAfter | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
setStartBefore | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
startContainer | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
startOffset | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
surroundContents | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
toString | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 4 | IE Full support 9 | Opera Full support 9 | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.
- Non-standard. Expect poor cross-browser support.
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.
- See implementation notes.
- See implementation notes.