473,698 Members | 2,833 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 5668
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
4866
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
3140
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
6435
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
4594
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
3240
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
2227
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
2879
by: ThunderMusic | last post by:
Hi, I think the subject says it all... thanks ThunderMusic
2
16411
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
1724
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
20486
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
8611
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,...
1
8904
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
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
7741
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...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
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...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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
3
2007
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.