RE: div coordinates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From a dhtml code:

    x=0; y=0; var el,temp
    el = document.getElementById("data");
    if(el.offsetParent){
      temp = el
      while(temp.offsetParent){ //Looping parent elements to get the
offset of them as well
        temp=temp.offsetParent;
        x+=temp.offsetLeft
        y+=temp.offsetTop;
      }
    }
    x+=el.offsetLeft
    y+=el.offsetTop

> -----Original Message-----
> From: php-objects@xxxxxxxxxxxxxxx [mailto:php-objects@xxxxxxxxxxxxxxx] On
> Behalf Of Farhan khalid
> Sent: 10 August 2007 23:08
> To: php-objects@xxxxxxxxxxxxxxx
> Subject:  div coordinates
>
> Hi,
>
> there is a div on page like <div id="data"></div>
>
> now by javascript i want to get the x,y coordinates of this div
>
> is this possible? we can take the x,y coordinates of the page but can we
> take
> coordinates of a div that is on that page where it is placed
>
> i need to get the coordinates and the send by ajax to a php page i can do
> that but i am unable to get the coordinates of div
>
> Regards
> Farhan


-- 
José Miguel Santibáñez
    jms@xxxxxxxxx

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux