var div = document.getElementById('div');
var p = getPos(div); function getPos(obj) { var pos = {left:0,top:0}; while(obj) {
pos.left += obj.offsetLeft;
pos.top += obj.offsetTop;
obj = obj.offsetParent;
}
return pos;
}
<div id="div" style="width:50px; height:50px; background:yellow; margin:50px 0 0 50px;"></div>