473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 4312
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike | last post by:
Hey guys I need some help with updateing an access database. I used OleDB controls to set up my connection, adapter, and dataset. The access table I am trying to update has these columns in this...
3
by: Epetruk | last post by:
Hi, I'm trying to design a simple web form, but I cannot get the code in the btnSubmit_ServerClick event to fire. What am I doing wrong? Here's the codebehind: using System; using...
14
by: John J. Hughes II | last post by:
Using the below code I am send multiple sterilized object across an IP port. This works fine if only one object is received at a time but with packing sometimes there is more then one object or...
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
19
by: felixnielsen | last post by:
Some might remember that i, not so long ago, started a treath or two about a weird 3d labyrinth. I now have a working code, that i want to share, hear comments, advice, ect., but first let me...
4
by: BrianKE | last post by:
I am attempting to create an app that will run "on top" of another app. My app will create a transparent window over the other app for the purpose of displaying information. I am able to create...
4
by: dropdeadster | last post by:
Trying to line up a tic-tac-toe board type grid of images using style= tags to <img inside a table TD but it's not working, I get more like a set of steps, can I get an explanation of what's wrong...
7
by: raylaur | last post by:
I'm using a javascript "slide" function to move a <div> layer in 10 pixel increments from one location on a page to another. The layer contains a GIF image. It's basically a side panel that flies out...
1
by: ced69 | last post by:
having trouble getting marquee to work get object required errors tring t <title>This Month at the Chamberlain Civic Center</title> <link href="styles.css" rel="stylesheet"...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.