DHTML Lab - DHTML Diner - Element Page Coordinates, Part 4 | 8 | WebReference

DHTML Lab - DHTML Diner - Element Page Coordinates, Part 4 | 8


Determining Element Page Coordinates, Part 4
IE Win - Final Comments

Accounting for 'Layout' Elements

In Part 2, when we examined the calculation of the position of elements nested in tables, we concluded:

  1. The border width of a table cell (TD) should be taken into account when calculating position.

  2. The border width of a table (TABLE) should not be taken into account when calculating position.

For the purposes of our calculations, the left border and top border widths were assigned by retrieving the TD element's clientLeft and clientTop properties.

We can now add:

  1. Any element that defines layout, and therefore exposes itself as an offsetParent, should have their border widths accounted for in any position calculations.

  2. The BODY element, being the top-most element in the element hierarchy should not have its border widths accounted for as we are attempting to find the position of an element within the body layout.

If we combine the above with the axioms from Part 2, we conclude:

All elements that define layout, except for table (TABLE) elements and the body (BODY) element, should have their border widths accounted for in any position calculations.

At least, for IE for Windows. We still have work to do for other browsers and platforms.

We have also come to the end of our discussion of IE for Windows, the most popular browser.

In the next installment, we'll end our discussion of NS6+ position retrieval, before moving on to other browsers.

On the next page, the functions are modified to incorporate what we have demonstrated in this article.



Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: Nov 21, 2002
Revised: Nov 21, 2002

URL: http://www.webreference.com/dhtml/diner/realpos4/8.html