Posted By

Leech on 07/28/08


Tagged

javascript absolute position


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Leech
wizard04
jodm


Get Absolute Position


 / Published in: JavaScript
 

URL: http://fromvega.com/wordpress/2007/07/14/easydrag-jquery-plugin/#comment-754

Returns absolute position of given object. Specially for crap-IE that do not detects correctly the .offset* attribute.

  1. function getPos (obj) {
  2. var output = new Object();
  3. var mytop=0, myleft=0;
  4. while( obj) {
  5. mytop+= obj.offsetTop;
  6. myleft+= obj.offsetLeft;
  7. obj= obj.offsetParent;
  8. }
  9. output.left = myleft;
  10. output.top = mytop;
  11. return output;
  12. }

Report this snippet  

You need to login to post a comment.