非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。
nodesFromPoint()
特性为
DocumentOrShadowRoot
interface returns an array of all nodes at the specified coordinates (relative to the viewport).
Currently this method is only implemented in Firefox, and only available to chrome code.
var nodes = document.nodesFromPoint(x, y);
The horizontal coordinate of a point.
The vertical coordinate of a point.
An array of
节点
对象。
<div> <p>Some text</p> </div> <p>Nodes at point 30, 20:</p> <div id="output"></div>
var output = document.getElementById("output");
if (document.nodesFromPoint) {
var nodes = document.nodesFromPoint(30, 20);
for(var i = 0; i < nodes.length; i++) {
output.textContent += nodes[i].localName;
if (i < nodes.length - 1) {
output.textContent += " < ";
}
}
} else {
output.innerHTML = "<span style=\"color: red;\">" +
"Browser does not support <code>document.nodesFromPoint()</code>" +
"</span>";
}
Not part of any specification at present.
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
nodesFromPoint
非标
|
Chrome No | Edge No |
Firefox
No
|
IE No | Opera No | Safari No | WebView Android No | Chrome Android No |
Firefox Android
No
|
Opera Android No | Safari iOS No | Samsung Internet Android No |
不支持
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
见实现注意事项。
DocumentOrShadowRoot
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