I'd like to know the absolute position (pixels from top and left) of a HTML element within an iFrame that has scrolled. I've tried using the 'findpos' script from quirksmode (http://www.quirksmode.org/js/findpos.html):
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
do {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
}
while (obj = obj.offsetParent);
return [curleft, curtop];
}
}
This doesn't seem to account for the fact that the iFrame may have scrolled. How can I modify this script to account for the scroll of the iFrame?