Range
インターフェイスは、ノードやテキストノードの部品を含むことができる文書の断片を表します。
Range は document
オブジェクトの createRange()
メソッドにより生成することができます。また、Selection
オブジェクトの getRangeAt()
メソッドや Document
オブジェクトの caretRangeFromPoint()
メソッドにより取得することもできます。
さらに、Range()
コンストラクターも使用できます。
プロパティ
継承しているプロパティはありません。
Range.collapsed
読取専用- Range の始点と終点が同じ位置にあるか否かを示す
Boolean
を返す Range.commonAncestorContainer
読取専用startContainer
とendContainer
をともに含む、最も深いNode
を返すRange.endContainer
読取専用Range
の終点を含むNode
を返すRange.endOffset
読取専用endContainer
の中でのRange
の終点の位置を示す数字を返すRange.startContainer
読取専用Range
の始点を含むNode
を返すRange.startOffset
読取専用startContainer
の中でのRange
の始点の位置を示す数字を返す
コンストラクター
メソッド
継承しているメソッドはありません。
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()
Range
の中身をDocument
から削除Range.extractContents()
Range
の中身をドキュメントツリーからDocumentFragment
に移動Range.insertNode()
Range
の始点にNode
を挿入Range.surroundContents()
Range
の中身を新しいNode
の中に移動Range.compareBoundaryPoints()
- 2 つの
Range
の端点の位置を比較 Range.cloneRange()
- 元の
Range
と同じ端点を持つRange
オブジェクトを返す Range.detach()
- パフォーマンスを改善するために、
Range
を使用状態から開放 Range.toString()
Range
の内容を文字列として返すRange.compareNode()
Node
が range の前、後、中、外のうちのいずれの場所にあるかを示す定数を返すRange.comparePoint()
- 指定された点が
Range
の前、中、後のうちのいずれの場所にあるかを -1、0、1 で示す Range.createContextualFragment()
- 渡された文字列から生成した
DocumentFragment
を返す Range.getBoundingClientRect()
Range
の内容の全体に結びつくDOMRect
オブジェクトを返します。これは、Range.getClientRects()
が返すすべての長方形の集合体です。Range.getClientRects()
Range
内のすべての要素について、Element.getClientRects()
の結果をまとめたDOMRect
オブジェクトのリストを返します。Range.intersectsNode()
- 指定ノードの範囲が
Range
と交差するか否かを示すboolean
を返す Range.isPointInRange()
- 与えられた点が
Range
の中にあるか否かを示すboolean
を返す
仕様書
仕様書 | 状態 | 備考 |
---|---|---|
DOM Range の定義 |
現行の標準 | 今後は RangeException は使用せず、代わりに DOMException を使用します。collapse() の第 2 引数を省略可能に変更。isPointInRange() , comparePoint() , intersectsNode() メソッドを追加。Range() コンストラクターを追加。 |
DOM Parsing and Serialization Extensions to Range の定義 |
草案 | createContextualFragment() メソッドを追加。 |
CSS Object Model (CSSOM) View Module Extensions to Range の定義 |
草案 | getClientRects() および getBoundingClientRect() メソッドを追加。 |
Document Object Model (DOM) Level 2 Traversal and Range Specification Range の定義 |
廃止 | s初回定義 |
ブラウザーの互換性
BCD tables only load in the browser