Volleynerd Knowledge Base

Saturday, February 19, 2005

Measuring Element Dimension and Location (Internet Explorer - DHTML)


Once in a great while, when I'm hacking on some DHTML code, I wonder how all the various coordinate values for objects are inter-related. This link below is the MSDN help page that shows the coordinate values in a graphical way.

Example: Show/hide DIV block with absolute positioning, and want it to show up near the user click. You have to take into account if the page is scrolled up a bit.

clientY will tell you where you are in the window, but doesn't account for scrolling.

HINT: use body.scrollTop to add to the clientY where the event was. But only if you have a reference to the BODY element - easiest way is obviously to give BODY an ID.

Measuring Element Dimension and Location (Internet Explorer - DHTML)

keywords: style visibility visible DHTML scrolling Internet Explorer IE




Comments: Post a Comment

Home