DOM
StaticRange
interface extends
AbstractRange
to provide a method to specify a range of content in the DOM whose contents don't update to reflect changes which occur within the DOM tree.
It offers the same set of properties and methods as
AbstractRange
.
AbstractRange
and
StaticRange
are not available from
web workers
.
<div id="interfaceDiagram" style="display: inline-block; position: relative; width: 100%; padding-bottom: 11.666666666666666%; vertical-align: middle; overflow: hidden;"><svg style="display: inline-block; position: absolute; top: 0; left: 0;" viewbox="-50 0 600 70" preserveAspectRatio="xMinYMin meet"><a xlink:href="../API/AbstractRange" target="_top"><rect x="1" y="1" width="130" height="50" fill="#fff" stroke="#D4DDE4" stroke-width="2px" /><text x="66" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">AbstractRange</text></a><polyline points="131,25 141,20 141,30 131,25" stroke="#D4DDE4" fill="none"/><line x1="141" y1="25" x2="171" y2="25" stroke="#D4DDE4"/><a xlink:href="../API/StaticRange" target="_top"><rect x="171" y="1" width="110" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="226" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">StaticRange</text></a></svg></div>
a:hover text { fill: #0095DD; pointer-events: all;}
StaticRange()
StaticRange
object given the
StaticRangeInit
dictionary specifying the default values for its properties.
The properties below are inherited from its parent interface,
AbstractRange
.
StaticRange.collapsed
只读
true
if the range's start and end positions are the same, resulting in a range of length 0.
StaticRange.endContainer
只读
节点
which contains the ending point of the range. The offset into the node at which the end position is located is indicated by
endOffset
.
StaticRange.endOffset
只读
endContainer
at which the last character of the range is found.
StaticRange.startContainer
只读
节点
which contains the starting point of the range (which is in turn identified by
startOffset
.
StaticRange.startOffset
只读
startContainer
at which the first character of the range is located.
StaticRange.toRange()
范围
object which describes the same range as the source
StaticRange
, but is "live" with values that change to reflect changes in the contents of the DOM tree.
A DOM range specifies a span of content in a document, potentially beginning inside one node (or element) and ending inside another one. Unlike a
范围
,
StaticRange
represents a range which is fixed in time; it does not change to try to keep the same content within it as the document changes. If any changes are made to the DOM, the actual data contained within the range specified by a
StaticRange
may change. This lets the
用户代理
avoid a lot of work that is unnecessary if the web app or site doesn't need a live-updating range.
| 规范 | 状态 | 注释 |
|---|---|---|
|
DOM
The definition of 'StaticRange' in that specification. |
实时标准 | |
|
Static Range
The definition of 'StaticRange' in that specification. |
编者草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
StaticRange
|
Chrome 60 | Edge 18 |
Firefox
69
注意事项
|
IE 不支持 No | Opera 47 | Safari 10.1 | WebView Android 60 | Chrome Android 60 | Firefox Android 不支持 No | Opera Android 44 | Safari iOS 10.3 | Samsung Internet Android 8.0 |
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 |
collapsed
|
Chrome 60 | Edge 18 | Firefox 69 | IE 不支持 No | Opera 47 | Safari 10.1 | WebView Android 60 | Chrome Android 60 | Firefox Android 不支持 No | Opera Android 44 | Safari iOS 10.3 | Samsung Internet Android 8.0 |
endContainer
|
Chrome 60 | Edge 18 | Firefox 69 | IE 不支持 No | Opera 47 | Safari 10.1 | WebView Android 60 | Chrome Android 60 | Firefox Android 不支持 No | Opera Android 44 | Safari iOS 10.3 | Samsung Internet Android 8.0 |
endOffset
|
Chrome 60 | Edge 18 | Firefox 69 | IE 不支持 No | Opera 47 | Safari 10.1 | WebView Android 60 | Chrome Android 60 | Firefox Android 不支持 No | Opera Android 44 | Safari iOS 10.3 | Samsung Internet Android 8.0 |
startContainer
|
Chrome 60 | Edge 18 | Firefox 69 | IE 不支持 No | Opera 47 | Safari 10.1 | WebView Android 60 | Chrome Android 60 | Firefox Android 不支持 No | Opera Android 44 | Safari iOS 10.3 | Samsung Internet Android 8.0 |
startOffset
|
Chrome 60 | Edge 18 | Firefox 69 | IE 不支持 No | Opera 47 | Safari 10.1 | WebView Android 60 | Chrome Android 60 | Firefox Android 不支持 No | Opera Android 44 | Safari iOS 10.3 | Samsung Internet Android 8.0 |
toRange()
|
Chrome 60 | Edge 18 | Firefox 不支持 No | IE 不支持 No | Opera 47 | Safari 不支持 No | WebView Android 60 | Chrome Android 60 | Firefox Android 不支持 No | Opera Android 44 | Safari iOS 不支持 No | Samsung Internet Android 8.0 |
完整支持
不支持
见实现注意事项。
范围
AbstractRange
, the abstract interface from which all ranges are derived
StaticRange
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
CSSPrimitiveValue
CSSValue
CSSValueList
CharacterData
ChildNode
注释
CustomEvent
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementation
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPoint
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMTokenList
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
节点
NodeFilter
NodeIterator
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
文本
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument