DOM:document.elementFromPoint
From MDC
This article covers features introduced in Firefox 3
Contents |
[edit] Summary
Returns the element from the caller's document at the given point, relative to the upper-left-most point in the (possibly scrolled) window or frame.
[edit] Syntax
element = document.elementFromPoint(x, y);
where
-
elementis an element object. -
xandyspecify the coordinates to check.
[edit] Example
<html>
<head>
<title>elementFromPoint example</title>
<script type="text/javascript">
function changeColor(newColor)
{
elem = document.elementFromPoint(2, 2);
elem.style.color = newColor;
}
</script>
</head>
<body>
<p id="para1">Some text here</p>
<button onclick="changeColor('blue');">blue</button>
<button onclick="changeColor('red');">red</button>
</body>
</html>
[edit] Notes
If the element at the specified point belongs to another document (for example, an iframe's subdocument), the element in the calling document's DOM (the iframe itself) is returned. If the element at the given point is anonymous or XBL generated content, such as a textbox's scroll bars, then the first non-anonymous parent element (for example, the textbox) is returned.
If the specified point is outside the visible bounds of the document or either coordinate is negative, the result is NULL.
onload event has fired before calling this method.[edit] Specification
- Preliminary specification:
elementFromPoint