"Mr. x" <a@b.com> writes:
<table id = "mytable" ....>
...
</table>
I want to get the left position of the table.
For what?
Everything I did getting wrong :
mytable.left doesn't work, neither mytable.style.left,
I hope mytable was declared by, e.g.,
var mytable = document.getElementById("mytable");
You should not expect to be able to use the name/id of an element
as a global variable, just because some browsers allow it.
mytable.getAttribute("left") ...
You haven't set the attributes style="left:..." or left="...", so
neither style.left nor getAttribute("left") should work.
What is the correct syntax for getting the position of the table element
(and others ...) ?
There is no official standard for this.
Many browsers allow you to write:
mytable.offsetLeft
That gives the box that this element is positioned relative to. Often,
that element is the document itself. If not, you can find the element
as mytable.offsetParent.
Some allow you to find the current CSS affecting the element:
IE:
mytable.currentStyle.left
Mozilla/Opera 7.2:
document.defaultView.getComputedStyle(mytable,""). left
However, the result of this is just "auto" if the element isn't
positioned.
Good luck.
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'