function findXY(obj) {
if (obj==null) return {x:0,y:0};
var coords=findXY(obj.offsetParent);
return {x:obj.offsetLeft-obj.scrollLeft+coords.x,y:obj.offsetTop-obj.scrollTop+coords.y};
}
var coords=findXY(document.getElementById("myId"));
The values coords.x and coords.y gives you the position of the DOM element from the top left corner of your web page.
This function is used to display sprite in this Ajax/javascript online Game. Check the javascript source code in the web page to see how it works.
How to get the absolute position of an element using javascript, Absolute positionning in javascript, Javascript element coordinates, Absolute screen position in javascript