title: FInd out position of html element in iframe
body: <p>I want to find out the position of an element which is in iframe. I am trying ot use:-</p>
  
  <pre><code>//Function to find the position of element on page
  function getElementPosition(elem){
    var posX = 0;
    var posY = 0;
    while(elem!= null){  
          posX += elem.offsetLeft;  
          posY += elem.offsetTop;  
          elem = elem.offsetParent;
      console.log("In function:" + elem.tagName + " " + posX + " " + posY);
    }                              
   return { x : posX, y : posY };  
  }
  </code></pre>
  
  <p>To get the list of all elements of iframe,</p>
  
  <pre><code>var doc1 = $('#page1').get(0).contentDocument; // page1 is id of iframe element
  var list1 = doc1.getElementsByTagName('*');
  console.log(list1.length);                     // Printing correctly
  var index = prompt("Enter element index");
  var elem1 = list1[index];
  var pos1 = getElementPosition(elem1);
  console.log("Positions:" + pos1.x + " " + pos1.y);
  </code></pre>
  
  <p>But this is not working. Initially elem is not null but elem.offsetParent is null in every case. Am i doing some wrong ?</p>
  
  <p>For some elements, it is working fine. But for some elements, offsetParent is coming null and so their offsetLeft is 0 and offetTop is 0. </p>
  
  <p>Is there any other way to find out position of each element.</p>
  
  <p>Thanks in advance..</p>