StaticRange() 构造函数创建新 StaticRange object representing a span of content within the DOM. It includes properties identifying the standard and end positions of the range as well as a Boolean indicating whether or not the range is collapsed (that is, empty).

句法

var staticRange = new StaticRange(rangeSpec)
					

参数

rangeSpec

要求 rangeSpec parameter is an object adhering to the StaticRangeInit dictionary. The four required rangeSpec properties are:

startContainer
节点 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 is found.

endContainer
节点 in which the end point of the range is located.
endOffset
The offset into the node indicated by endOffset at which the last character in the range is located.

返回值

新的 StaticRange object initialized with the values given in the rangeSpec 对象。

异常

InvalidNodeTypeError
DOMException fired if either or both of the startContainer and/or endContainer are a type of node which you can't include in a range. Those node types are Node.DOCUMENT_TYPE_NODE (representing the DocumentType node derived from the DTD identified using the doctype preamble in the HTML, for example) and the Attr node describing an attribute of an element on the DOM..

规范

规范 状态 注释
DOM
The definition of 'StaticRange()' in that specification.
实时标准 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
StaticRange() 构造函数 Chrome 不支持 No Edge 不支持 No Firefox 71 IE 不支持 No Opera 不支持 No Safari 13.1 WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 13.4 Samsung Internet Android 不支持 No

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改: