componentFromPoint Method

DHTML, HTML, & CSS

componentFromPoint Method


Returns the component located at the specified coordinates.

Syntax

sScrollComponent = object.componentFromPoint(iCoordX, iCoordY)

Parameters

iCoordX Required. Integer that specifies the client window coordinate of x.
iCoordY Required. Integer that specifies the client window coordinate of y.

Return Value

String. Returns one of the following possible values:

""Component is inside the client area of the object.
outsideComponent is outside the bounds of the object.
scrollbarDownDown scroll arrow is at the specified location.
scrollbarHThumbHorizontal scroll thumb or box is at the specified location.
scrollbarLeftLeft scroll arrow is at the specified location.
scrollbarPageDownPage-down scroll bar shaft is at the specified location.
scrollbarPageLeftPage-left scroll bar shaft is at the specified location.
scrollbarPageRightPage-right scroll bar shaft is at the specified location.
scrollbarPageUpPage-up scroll bar shaft is at the specified location.
scrollbarRightRight scroll arrow is at the specified location.
scrollbarUpUp scroll arrow is at the specified location.
scrollbarVThumbVertical scroll thumb or box is at the specified location.
handleBottomBottom sizing handle is at the specified location.
handleBottomLeftLower-left sizing handle is at the specified location.
handleBottomRightLower-right sizing handle is at the specified location.
handleLeftLeft sizing handle is at the specified location.
handleRightRight sizing handle is at the specified location.
handleTopTop sizing handle is at the specified location.
handleTopLeftUpper-left sizing handle is at the specified location.
handleTopRightUpper-right sizing handle is at the specified location.

Remarks

The componentFromPoint method, available as of Microsoft® Internet Explorer 5, is applicable to any object that can be given scroll bars through cascading style sheets (CSS).

The componentFromPoint method may not consistently return the same object when used with the onmouseover event. Because a user's mouse speed and entry point can vary, different components of an element can fire the onmouseover event. For example, when a user moves the mouse cursor over a TEXTAREA object with scroll bars, the event may fire when the mouse enters the component border, the scroll bars, or the client region. Once the event has fired, the expected element may not be returned unless the scroll bars were the point of entry for the mouse. In this case, the onmousemove event can be used to provide more consistent results.

For the object's sizing handles to appear, designMode must be on and the object must be selected.

Example

This example uses the componentFromPoint method to determine which object the mouse pointer is hovering over.

Sample Code

<HEAD>
<SCRIPT>
function trackElement(){
   var sElem = "";
   sElem = document.body.componentFromPoint(
      event.clientX,
      event.clientY
   );
   window.status = "mousemove " + event.clientX + ", "
      + event.clientY +
      " The mouse pointer is hovering over: " + sElem;
}
</SCRIPT>
</HEAD>
<BODY onmousemove="trackElement()">
<TEXTAREA COLS=500 ROWS=500>
This text forces scroll bars to appear in the window.
</TEXTAREA>
</BODY>

This feature requires Internet Explorer 5 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
A, ACRONYM, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BDO, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, custom, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, HEAD, Hn, HR, HTML, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, ISINDEX, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, NEXTID, NOBR, NOFRAMES, NOSCRIPT, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, RT, RUBY, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, WBR, XML, XMP

See Also

doScroll, onScroll


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.