By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,472 Members | 1,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,472 IT Pros & Developers. It's quick & easy.

some problem of getting the position of an object

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
"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

P: n/a
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

P: n/a
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.