Packagecssom.view
Interfacepublic interface DocumentView
Implementors Document

Introduced in: DOM 0 
Modified in: DOM 3 Core 

Has a method that gives position information about an Element node relative to the Document.

DocumentView contains many properties and a few methods that were previously not part of any specification. They originated as part of MSIE's DHTML object model. They are now all part of the CSSOM Views specification which should be implemented on any browser supporting DOM 3 Core.

All browser compatibility information was obtained via Quirksmode.

Note: This conflicts with an interface in DOM 2 Views. Maybe this specification combined with HTML 5 (for AbstractView) can obsolete that one as it is completely useless in practice.

See also

W3C CSSOM Views Specification: DocumentView
Quirksmode: W3C DOM Compatibility - CSS Object Model View


Public Methods
 MethodDefined By
  
CSSOM View elementFromPoint(x:Number, y:Number):Element
Returns the element from the document whose elementFromPoint method is being called which is the topmost element which lies under the given point.
DocumentView
Method Detail
CSSOM View elementFromPoint()method
public function elementFromPoint(x:Number, y:Number):Element

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.1b Safari 3.0 Safari 3.1 Safari 4.0b Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 10.0a
Introduced in: DOM 0 
Modified in: DOM 3 Core 

Returns the element from the document whose elementFromPoint method is being called which is the topmost element which lies under the given point.

The point is specified via coordinates, in CSS pixels, relative to the upper-left-most point in the window or frame containing the document.

Note: If the element at the specified point belongs to another document (for example, an iframe's subdocument), the element in the DOM of the document the method is called on (in the iframe case, 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 ancestor element (for example, the textbox) is returned.

Note: If the specified point is outside the visible bounds of the document or either coordinate is negative, the result is null.

Note: The browsers do not entirely agree which mouse coordinates this method needs. IE and Firefox 3 need clientX/Y (relative to the viewport), while Opera and Safari need pageX/Y (relative to the document).

Parameters

x:Number — The X coordinate to check, in CSS pixels relative to the upper-left corner of the document's containing window or frame.
 
y:Number — The Y coordinate to check, in CSS pixels relative to the upper-left corner of the document's containing window or frame.

Returns
Element — The element at x,y in the viewport

See also


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>