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

current coordinates of an element

35
is there a way in javascript to retrieve the current coordinates of an element on screen with respect to the page viewport as well as the screen.?
i'm having this case where i have an INPUT element inside a DIV element and i have to scroll vertically through the DIV to view it.I want to get its coordinates when it is visible on the screen (ie. the coordinates that typically make it visible)
before scroll
x=232
y=2225

after scroll
x=232
y=384 // should be but it's always 2225.

i'm stuck on something else, what would i do to retrieve the coordinates of a KeyEvent?
Oct 26 '07 #1
1 1751
gits
5,390 Expert Mod 4TB
hi ...

you may use the onscroll-event to observe the event - add that handler ... with that you may normalize the coordinates to your viewport. for that you may use the pageXOffset, pageYOffset and/or srcollLeft, scrollTop coordinates in IE ... so the scrolling moves the viewport and you may write a function that computes the visibility when the current scroll-position makes your element visible ...

kind regards
Oct 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Berk Birand | last post by:
Hi, I am new to Perl (as a matter of fact, I started learning it a couple of days ago; I have some previous programming experience though). When looking for the ideal languages to use for a...
1
by: Siegfried Heintze | last post by:
I want to implement drag and drop for tables, divs, spans. The problem is that I don't know how wide or long my tables, divs and spans are going to be in advance so I cannot use absolute...
15
by: Tony Gahlinger | last post by:
I'm using my browser (Mozilla/5.0 Linux i686 Gecko/20031007 Firebird/0.7) to do some client-side image processing. I want to capture the sequence of coordinates a user clicks on in xxx.jpg in the...
1
by: Dave Hammond | last post by:
I have an html element (a link) with an onclick handler which opens a popup window, and would like to position that window at the coordinates where the element appears on the page. I have...
1
by: Roger | last post by:
I am trying to capture the image coordinates when a user clicks on an image. My code is working in Firefox, Mozilla, Netscape, IE, and Opera, but fails under Konqueror (and I suspect Safari). ...
3
by: hclarius | last post by:
Is there any way programmatically to get the values of the PrintDocument's current position (x and y)? Thanks
4
by: Tomasz Bak | last post by:
Hello, I have a simple problem: mark a list of defects on an image. I think the best way to do it is to select a single deffect, then take two coordinates of coursor form an image on a web...
3
by: Doug | last post by:
Hi I am trying to find a way to make the mouse cursor move to the keyboard cursor position in an application. For example, I use an application called Enterprise Guide, and I control this...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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,...

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.