
Код HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<div style="padding: 3em;"><div style="margin:30ex;"><nobr>текст <span id="new">s</span></nobr></div></div>
<script>
function getTop(el){
var of = el.offsetTop;
while(el.offsetParent){
el = el.offsetParent;
of += el.offsetTop;
}
return of;
}
function getLeft(el){
var of = el.offsetLeft;
while(el.offsetParent){
el = el.offsetParent;
of += el.offsetLeft;
}
return of;
}
alert(["> ",getTop(document.getElementById("new")), getLeft(document.getElementById("new"))]);
</script>
</body>
</html>