|
Hi Group,
I've found it's difficult to find the absolute position of table in browsers. Here is an example:
<html>
<head>
<title>Test Position</title>
<script language='javascript'>
function objById(id){
return document.getElementById(id);
}
function showPosition(id){
var obj = objById(id);
var xx = obj.offsetLeft;
var yy = obj.offsetTop;
var h = obj.offsetHeight;
for(obj = obj.offsetParent; obj != null; obj = obj.offsetParent){
xx += obj.offsetLeft;
yy += obj.offsetTop;
}
alert(id + ":" + xx + "," + yy + "," + h);
}
</script>
</head>
<body onload=showPosition('table1') style='margin:0'>
<table id='table1' width=60% height=200 bgcolor=gray align=center style='position:relative;left:0;top:20;'>
<tr><td>this is a table</td></tr>
</table>
</body>
</html>
The showPosition('table1') gives: 0,20,200. The left postion is obviosly wrong with 'align=center'.
It's appreciated greatly for any help!
|
|
|
|
|
|
|
|