473,398 Members | 2,380 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,398 software developers and data experts.

how to retrieve DIV position???

Hi, I was wondering how to retrieve the cordinates of a CSS layer with
javascript.

I set the layer cordinates as like this in the header:

<style type="text/css">
..classID {
position: absolute;
left: 2px;
top: 100px;
}
</style>

then in the body I have:

<div id="layerID" class="classID">
some html and text
</div>

The layer positions properly so I know that works.

and then in a javascript function I try to retrieve the cordinates by:

toppos = document.getElementById("layerID").style.top;
leftpos = document.getElementById("layerID").style.left;

but leftpos and toppos always come back blank.
Thanks in advance!
Billy
Jul 20 '05 #1
4 9990
Billy wrote:
Hi, I was wondering how to retrieve the cordinates of a CSS layer with
javascript.


Is getComputedStyle something for you? Sample article:

http://www.csie.ntu.edu.tw/~b7506051...examples7.html

--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Jul 20 '05 #2
Thanks!

"Bas Cost Budde" <ba*@heuveltop.org> wrote in message
news:bv***********@news2.solcon.nl...
Is getComputedStyle something for you? Sample article:

http://www.csie.ntu.edu.tw/~b7506051...examples7.html

Jul 20 '05 #3
DU
Billy wrote:
Hi, I was wondering how to retrieve the cordinates of a CSS layer with
javascript.

I set the layer cordinates as like this in the header:

<style type="text/css">
.classID {
position: absolute;
left: 2px;
top: 100px;
}
</style>

then in the body I have:

<div id="layerID" class="classID">
some html and text
</div>

The layer positions properly so I know that works.

and then in a javascript function I try to retrieve the cordinates by:

toppos = document.getElementById("layerID").style.top;
leftpos = document.getElementById("layerID").style.left;

but leftpos and toppos always come back blank.

It should not... unless layerID has moved, was dynamically moved: you do
not say that in your post description.

Thanks in advance!
Billy


var toppos, leftpos;

toppos = parseInt(document.getElementById("layerID").style. top, 10);
leftpos = parseInt(document.getElementById("layerID").style. left, 10);

DU
Jul 20 '05 #4
DU
Bas Cost Budde wrote:
Billy wrote:
Hi, I was wondering how to retrieve the cordinates of a CSS layer with
javascript.

Is getComputedStyle something for you? Sample article:

http://www.csie.ntu.edu.tw/~b7506051...examples7.html


But this will only work in DOM 2 Views and DOM 2 CSS compliant browsers.
MSIE 6 for windows does not support DOM 2 Views and has limited support
for DOM 2 CSS.

DU
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: forums_mp | last post by:
I've got an STL class (see below) with two functions to store and retrieve data - msg structs. The "Store" function when called will copy the received message (depending on which message) into...
2
by: Billy | last post by:
Hi, This is in connection to the tread: Re: changing browser text settings?? I am wondering if there is a way to retrieve the browsers text size (not change! ;-) ) so that I can dynamically...
79
by: Klaus Bonadt | last post by:
In order to protect software from being copied without licence, I would like to use something like a key, which fits only to the current system. The serial number of the CPU or the current...
2
by: MyndPhlyp | last post by:
For IE, I can retrieve an array of tags using: document.all.tags("tagname") For NS6 & 7 I can use: document.getElementsByTagName("tagname") Is there an equivalent for that ancient NS...
1
by: zoltix | last post by:
Hi, How to retrieve a value in in an aspx page? Normally it is easy, drag and drops the textarea in aspx page and it is work. But in this case, I generate the html code manually () and put as...
1
by: Jan Van Steenbergen | last post by:
Hi all i'm having a little problem I have a aspx file with a iFrame defined The iframe is loaded with a html webeditor After editing data in the webeditor textbox, i want t get the data to a...
13
by: no.mail.pls | last post by:
Hiya, How do i retreive fields with similar values from 2 tables? I tried to use (1) "SELECT * FROM $table1 as o , $table2 as p WHERE o.name like '%p.name%'"; but it retrieves nothing at...
4
by: joanjy86 | last post by:
;) Hi, I met with some problems with my Visual Basic codings...I need to retrieve certain texts or characters from the text file and place it in each different textboxes...How do i start with? :eek:...
39
by: Kapil Choubisa | last post by:
Hi!!!!!!!! All, I am facing a problem to retrieving parent node. I have Child node already I am using Xpath. Here is my XML:::::: <book> <chapters>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.