Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. StaticRange
  4. StaticRange()

StaticRange: StaticRange() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨April 2021⁩.

TheStaticRange() constructorcreates a newStaticRange object representing a span of content withinthe DOM.

This constructor includes properties identifying the start and end positions ofthe range as well as a Boolean indicating whether or not the range iscollapsed (that is, empty).

Syntax

js
new StaticRange(rangeSpec)

Parameters

rangeSpec

The requiredrangeSpec parameter is an objectcontaining the four following properties:

startContainer

TheNode in which the starting point of the range is located.

startOffset

The offset into the starting node at which the first character of the range isfound.

endContainer

TheNode in which the end point of the range is located.

endOffset

The offset into the node indicated byendOffset at which the lastcharacter in the range is located.

Return value

A newStaticRange object initialized with the values given intherangeSpec object.

Exceptions

InvalidNodeTypeError

ADOMException fired if either or both of thestartContainer and/orendContainer are a type of node whichyou can't include in a range. Those node typesareNode.DOCUMENT_TYPE_NODE (representing theDocumentTypenode derived from theDTD identified using thedoctypepreamble in the HTML, for example) and theAttr node describing anattribute of an element on the DOM.

Specifications

Specification
DOM
# ref-for-dom-staticrange-staticrange①

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp