ho trovato con google.... :quipy:
codice:
<script type="text/javascript">
// this function returns the x, y position
// works in IE and Mozilla.
function getElementPosition(element){
var x=0,y=0;
while (element!=null){
x+=element.offsetLeft-element.scrollLeft;
y+=element.offsetTop-element.scrollTop;
element=element.offsetParent;
}
return {x:x,y:y};
}
// Browser compatible element getter
function getElement(id){
if (document.all)
return document.all[id];
if (document.getElementById(id))
return document.getElementById(id);
return null;
}
// generic display function
function findElement(id){
// Get the element by its id
element = getElement(id);
// make sure that the element was found
if (! element) return;
// get the object that will contain the x,y coordinates
position = getElementPosition(element);
// display the coordinates
alert('x: ' + position.x + '\n\ny: ' + position.y);
}
</script>