[Javascript] Show full text in pop up window - finding object position

Paul Novitski paul at dandemutande.org
Thu Mar 18 14:46:55 CST 2004


On the subject of finding the position of an object, Peter-Paul Koch has an 
excellent discussion & script on his page:
http://www.quirksmode.org
Navigate to Javascript / DHTML / Find position

Paul



At 11:49 AM 3/18/2004, I wrote:
...
>One way to find the position of an object on the screen is to add its 
>position to the positions of all of its parent containers:
>
>var oObj = oThingie;
>var iTotalTop = 0;
>var iTotalLeft = 0;
>
>while (oObj){
>         iTotalTop += oObj.offsetTop;
>         iTotalLeft += oObj.offsetLeft;
>         oObj = oObj.offsetParent;
>}
>
>This loop continues to walk up the DOM until it reaches the top.  It could 
>be elaborated to include margins & padding when appropriate.
>
>I've used this successfully only when beginning with an image within a 
>table cell, but perhaps someone else here could tell me how to begin with 
>the <td> itself.





More information about the Javascript mailing list