469,579 Members | 1,256 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

some problem of getting the position of an object

Hello,
I have simple table
<table id = "mytable" ....>
....
</table>

I want to get the left position of the table.

Everything I did getting wrong :

mytable.left doesn't work, neither mytable.style.left,
mytable.getAttribute("left") ...

What is the correct syntax for getting the position of the table element
(and others ...) ?

Thanks :)
Jul 20 '05 #1
3 4207
"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.'
Jul 20 '05 #2
VK
unless you explicitly positioned an object on the page (absolutely or
relatively), it's position is "null" meaning "wherever the HTML Parser
(disposed by now so not available) placed me during the page rendering".
Jul 20 '05 #3
The problem is that,
when I have found a javascript scroller (marquee - a scroller of multiple
lines), and I want to change it a little bit, so it fits the coordinates of
my object (that's why I need some way to get the left, top ... of my
object),
and not at a fixed position, so I need to know what is the top, left, right
& bottom of my object.
I would like a javascript scroller maker, or a script for scrolling lines,
that enable some quick changes that it will fit my objects positions,
please.

Thanks :)

"VK" <sc**********@yahoo.com> wrote in message
news:3f***********************@news.freenet.de...
unless you explicitly positioned an object on the page (absolutely or
relatively), it's position is "null" meaning "wherever the HTML Parser
(disposed by now so not available) placed me during the page rendering".

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mike | last post: by
3 posts views Thread by Epetruk | last post: by
14 posts views Thread by John J. Hughes II | last post: by
19 posts views Thread by felixnielsen | last post: by
4 posts views Thread by BrianKE | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.