I am trying to get the position of an element (password input) on the webpage http://login.secureserver.net/index.php?app=wbe . I type this code in the javascript console in Chrome
function fp(obj){
var x=0,y= 0;
if (obj.offsetParent) {
do {
x+= obj.offsetLeft;
y+= obj.offsetTop;
} while (obj = obj.offsetParent);
}
};
fp(document.getElementById('password'));
console.log("x="+x+"; y="+y)
and it returns x=809; y=380.
When measuring the screenshot with photoshop it appears to have x=816; y=388.
So what's the problem and why it is not returning the real distance?