How to calculate X and Y of a div?

How to calculate X and Y of a div?

Hi,
I want to calculate X and Y of a div, but I get an infinite loop, can you tell me please what's the problem with my code?

  1. Left = Obj.offset().left;
  2. while(Obj.offsetParent()!=null)
  3. {
  4.      ObjParent = Obj.offsetParent();
  5.      Left += ObjParent.offset().left;
  6.      Obj = ObjParent;
  7. }
What do you think?