We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

Leech on 07/28/08


Tagged

javascript absolute position


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

Leech
wizard04


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.