这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
Range.comparePoint()
方法返回
-1
,
0
,或
1
depending on whether the
referenceNode
is before, the same as, or after the
范围
.
若
reference node
是
节点
类型
文本
,
注释
,或
CDATASection
, then offset is the number of characters from the start of
reference node
. For other
节点
types, offset is the number of child nodes between the start of the
reference node
.
returnValue = range.comparePoint(referenceNode, offset)
referenceNode
节点
to compare with the
范围
.
offset
range = document.createRange();
range.selectNode(document.getElementsByTagName('div').item(0));
returnValue = range.comparePoint(document.getElementsByTagName('p').item(0), 1);
| 规范 | 状态 | 注释 |
|---|---|---|
|
DOM
The definition of 'Range.comparePoint()' in that specification. |
实时标准 | 最初的规范。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
comparePoint
|
Chrome Yes | Edge 17 | Firefox Yes | IE No | Opera 15 | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android 14 | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
不支持
实验。期望将来行为有所改变。
范围
cloneContents()
cloneRange()
collapse()
compareBoundaryPoints()
compareNode()
comparePoint()
createContextualFragment()
deleteContents()
detach()
extractContents()
getBoundingClientRect()
getClientRects()
insertNode()
intersectsNode()
isPointInRange()
selectNode()
selectNodeContents()
setEnd()
setEndAfter()
setEndBefore()
setStart()
setStartAfter()
setStartBefore()
surroundContents()
toString()
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
StaticRange
文本
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument