473,320 Members | 1,951 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,320 software developers and data experts.

Layer Positioning

Thank you in advance.
I have a table with a <DIV> in it and would like to get the left
property of the <DIV>. It comes back 0. I would like to get the the
position relative to the screen (like 354). Is this possible? If so
could you please point me in the right direction?

Thanks

<TABLE ALIGN="center">
<TR>
<TD>
<DIV>Some Text</DIV>
</TD>
</TR>
</TABLE>

Feb 18 '06 #1
1 1220
Pondering the eternal question of "Hobnobs or Rich Tea?",
un**********@mchsi.com finally proclaimed:
I have a table with a <DIV> in it and would like to get the left
property of the <DIV>. It comes back 0. I would like to get the the
position relative to the screen (like 354). Is this possible? If so
could you please point me in the right direction?


I found the following functions somewhere a while ago:

/*
Function to find the x position of the top left corner of
a given object
*/
function findPosX(obj) {
var curleft = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}

/*
Function to find the y position of the top left corner of
a given object
*/
function findPosY(obj) {
var curtop = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}

I'm sure they can be improved upon, but they've done the job for me on
many occasions!

--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references
Feb 18 '06 #2

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

Similar topics

1
by: Question | last post by:
I am making a custom small menu which is most basic. Problem is that I can't make the first step work for some reason. I have an image to the left of where would be the layer positioned. This...
1
by: PAD | last post by:
I have written a javascript routine that populates a parent document with a series of <iframe>s. Each <iframe> receives its contents from a series of separate smaller HTML files. Of course my NN...
0
by: Wally Sanford | last post by:
I have a layer in a table at http://home.earthlink.net/~wallysanford/ that displays about how I'd like in IExplorer but is several pixels low in Netscape 7.x/6.x, Mozilla, Galeon, and Konqueror. ...
1
by: Chris McGarry | last post by:
Hello, I'm new to style sheets and have been fighting with browser compatibility for two days. I'm developing a image selection page (similar to Ebay where the visitor can select and enlarge 1-6...
10
by: Peter Altenberg | last post by:
is there some way to make the positioning of a layer (div) so that it is centered in the window. so even when you resize the window it stays centered? i would like to do this with CSS just like you...
2
by: Rolf Brauser | last post by:
Hi, is it possible to position a div layer from an external ccs file? thanks for help rolf
4
by: Manny | last post by:
Hi, I would like to display a small html file in a layer (div) when the mouse goes over a link (<a href="small.html" onMouseOver="showPop(small.html)"). Which tag should I use in the layer :...
87
by: expertware | last post by:
Dear friends, My name is Pamela, I know little about CSS, but I would like to ask a question I have an image on a web page within a css layer: <DIV ID=MyLayer STYLE = "position:...
8
by: nescio | last post by:
hello, i have a script that finds the x and y from the mouse position, this works fine. but now i have an image in a layer : <div id='someLayer'> <img src='someImage.jpg'> </div>
2
by: Chris | last post by:
I am working with javascript showing/hiding layers. If I am using a link's onclick to show a layer how do I make the layer show beside the link? There are many links on the page that may trigger...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.