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.

Find An Object's Page Position On Any Page - Version 0.1

I've never found a function which will return me the x,y position of an
object on the page reliably, cross-browser, in any type of page layout
situation. So, I've been working on my own function to accomplish this. If
anyone knows of a solution which already exists, please do let me know.

Here is my test page so far:
http://www.mattkruse.com/javascript/...sitionTest.php

My goal is to reliably return an object's position on the page and have it
work:
--------------------------------------------------------------------------------
a) In all the "major" browsers, at least
b) Regardless of the doctype being missing, being loose, or being strict
c) Even if the layout includes scrollable divs and other layouts which often
cause other scripts to break

My code accomplishes these goals as closely as I have been able to get so
far.

I would love to hear feedback on any or all of the following:
-------------------------------------------------------------
a) Results in browsers which I haven't already tested (a test summary is
included at the top of the page)
b) Techniques for solving the few browser quirks that exist, like IE's
problem with relatively positioned items, or Netscape 6.2's inability to get
the scroll position of an overflowed div
c) Most test cases which I haven't covered that might cause problems in
browsers, or which might exist in common page layouts

The code is not packaged up nicely or anything right now, and it has a lot
of debugging comments in it. Once I get everything working more solidly,
I'll clean that up.

Any input would be greatly appreciated!

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Aug 14 '05 #1
1 1731
ASM
Matt Kruse wrote:
I've never found a function which will return me the x,y position of an
object on the page reliably, cross-browser, in any type of page layout
situation. So, I've been working on my own function to accomplish this. If
anyone knows of a solution which already exists, please do let me know.

Here is my test page so far:
http://www.mattkruse.com/javascript/...sitionTest.php

My goal is to reliably return an object's position on the page and have it Any input would be greatly appreciated!


Mac G4 MacOs 10.3.7

FireFox 1.0.4 :
blue square over red one (every tests)
- tests 3 and 10 (3 modes) :
scroll of overflowes : the blue square doesn't move / window
(same with whole tried browsers)

IE 5.2 :
- bottom right corner blue square
positioned on top left corner red square

iCab 3.0 beta280 :
- 1 : ok
- 2 : fiew px up (top blue square = top cell)
- 3 : top blue square = top of div
(if scroll before click :
blue square up from link = up-space of div
blue square not displayed in div nor on red square)
- 4 : with any of my browsers I can scroll inside this div ... (?!)
blue from red : up = 60px / left = 150px
- 5, 6, 7 : top blue = top free space of line
- 9 : top blue = top cell
- 10 : top blue = top litle overflow
scrolls overflowes : blue doesn't move
scrolls window : blue scrolls with it

Opera 8.01 :
all seem so correct that for Windows (top blue = top red)
--
Stephane Moriaux et son [moins] vieux Mac
Aug 14 '05 #2

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

Similar topics

9
by: Keith Rowe | last post by:
Hello, I am trying to reference a Shockwave Flash Object on a vb code behind page in an ASP.NET project and I receive the following error: Guid should contain 32 digits with 4 dashes...
1
by: Anna K. | last post by:
Hi Experts, I'm new to JavaScript and web-based apps development, so I'll tell you right off that I don't really know my way around it as of yet. I'm trying to create a code library set with...
10
by: dale zhang | last post by:
Hi, I saw the post here about setfocus. But they are for web form. Web control page HTML does not have form1. the Jscript there does not work here. My question is how to set focus to the...
10
by: yop | last post by:
All When I try to get the text from my listbox I am get an error which is listed below. Any ideas? Thanks Object reference not set to an instance of an object.
4
by: Aaron Smith | last post by:
Dim dv As DataView = New DataView(FacilitiesDS1.Facilities, "", "ID ASC", DataViewRowState.CurrentRows) Dim iPos As Integer = dv.Find(dr.Item("ID")) Me.BindingContext(FacilitiesDS1,...
4
by: vunet.us | last post by:
I have a DIV element. How can I find mouse position (top and left) inside of this DIV? <div onMouseMove="getPositions();" style="width:200px;height:100px"></div> function getPositions(ev){...
2
by: everly | last post by:
Hi, I'm helping my friends band and making their MySpace. I messed something up and I can't figure out what it is. Everything is all out of whack on the bottom half of the page. The comments...
0
by: cleary1981 | last post by:
Hi, Heres my xsl stylesheet. Its work in progress but it works. What I want to do however is to make one page in the middle (drawings) a landscape page. Can anyone explain how to do this as all...
6
by: =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post by:
I followed the instructions from MSDN for Webclient UploadFile and I get an error: Could not find file 'C:\testfile.xls'. If I add the file (c:\testfile.xls) to the server I do not get the error...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.