473,729 Members | 2,309 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Absolute position?

Hi,

Is it possible to get absolute position of element with javascript?
e.g. I have textbox somewhere in table. Textbox relative to table cell
position is 0,0. How can I get Textbox absolute position on page??
Please, any ideas, I'm going crazy...

thanks
Nov 8 '06 #1
4 5671
Found it :)

txtQuery.offset Left

txtQuery.offset Top

"Samuel" <s@s.comwrote in message news:ei******** **@ss408.t-com.hr...
Hi,

Is it possible to get absolute position of element with javascript?
e.g. I have textbox somewhere in table. Textbox relative to table cell
position is 0,0. How can I get Textbox absolute position on page??
Please, any ideas, I'm going crazy...

thanks

Nov 8 '06 #2
AAARRRGGHHHH!!!

It dosen't work if textbox is in table, txtQuery.offset Top returns only
relative to table cell....

"Samuel" <s@s.comwrote in message news:ei******** **@ss408.t-com.hr...
Found it :)

txtQuery.offset Left

txtQuery.offset Top

"Samuel" <s@s.comwrote in message news:ei******** **@ss408.t-com.hr...
>Hi,

Is it possible to get absolute position of element with javascript?
e.g. I have textbox somewhere in table. Textbox relative to table cell
position is 0,0. How can I get Textbox absolute position on page??
Please, any ideas, I'm going crazy...

thanks


Nov 8 '06 #3
Samuel wrote:
It dosen't work if textbox is in table, txtQuery.offset Top returns only
relative to table cell....
Walk the offsetParent axis and add offsetTop and offsetLeft e.g.

function getPageCoords (element) {
var coords = { x: 0, y: 0 };
while (element) {
coords.x += element.offsetL eft;
coords.y += element.offsetT op;
element = element.offsetP arent;
}
return coords;
}

var coords = getPageCoords(s omeElement);
// use coords.x and coords.y here

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 8 '06 #4
Samuel wrote:
Is it possible to get absolute position of element with javascript?
Yes. For a general solution that works in most environments, see:
http://www.JavascriptToolbox.com/lib/objectposition/

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Nov 8 '06 #5

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

Similar topics

6
4873
by: Harald Kirsch | last post by:
In the W3C document about CSS2, I read at http://www.w3.org/TR/REC-CSS2/visuren.html#choose-position the following: absolute The box's position (and possibly size) is specified with the 'left', 'right', 'top', and 'bottom' properties. These properties
4
3141
by: Peter Pfannenschmid | last post by:
Hello experts, I would be very grateful if you would have a look at the following URL: http://www.omeganet.de/test.html The html file and the associated style have been validated successfully by the online validators of w3.org.
2
6438
by: Joachim Bauer | last post by:
I'm using the code below to display a menu that opens when the mouse goes over the main menu item (try it in your browser to understand the behaviour). It uses "position:absolute" and a switch between "display='none'" and "display=''". However the problem is that - in Internet Explorer 6 the dropdown (<select>...) always hides the menu
4
4609
by: mike eli | last post by:
Hi, I have several absolute positioned elements inside an absolute positioned DIV. I would like one of the nested elements to have a dynamic width. I set it's left and right attributes to 5, so the the element should have a width = parentWidth - 10; This is the desired behaviour, but it won't work. I still have to specify a width or the element has a width of 0. Setting the width to '100%' doesn't give me the desired effect; it takes...
7
3242
by: Alex | last post by:
Hi Everone, I need some advice on how to setup 4 columns where the outside two are absolute (120px) and the inner two (side by side) are relevent (Fluid) and change with the screen. Here's my rough layout:
3
2229
by: horusprim | last post by:
Is there a CSS absolute positioning rendering bug in FF1.02 and IE 6? I have been experimenting with precision absolute positioning in CSS. The following test content was used in the experiment: "This sentence is to be about nine words long. I hope this test suite works. Mary had a little lamb and its fleece was white as snow." Next a macro was used to divide the content into equal sentence fragment spans of the 12 characters each...
6
2880
by: ThunderMusic | last post by:
Hi, I think the subject says it all... thanks ThunderMusic
2
16417
by: nino9stars | last post by:
Hello, I have just started messing with absolute positioning on webpages, and it definitely let's you do some creative things. Well, after much searching and help, I got the images I was using to overlap correctly. You can see it on this page: www.creativekaysjewelry.com The images overlap exactly how I wanted and in the right position
0
1725
by: sknonline | last post by:
Greetings. I am having troubles using absolute positioning in IE6. When I establish the width as 100%, it's not spanning the entire width of the browser. It works in Firefox, Safari, and IE7.... Just not IE6. Any suggestions? Website: stevenkneff.com code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
7
20491
by: chemlight | last post by:
I am having an issue with HTML elements not printing when positioned absolutely when they extend beyond the first page. I am working on some foreign tax refund forms. The forms are cut into multiple jpg images, so that I can position them on the HTML page, so that they print properly (page1, page2, etc). The information to complete the forms is then positioned using position: absolute and a z-index of +1. Here is an example code of my...
0
8917
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9142
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8148
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.