473,513 Members | 2,399 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the current cursor position using clientX,clientY

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 installed a
document.onclick event handler which saves the eventX and eventY
values, then use those values to set the window top/left coordinates.

The problem is that the eventX and eventY values always seem to be the
previous coordinates, not the current ones. In other words, the first
time that I click the element, no coordinates have been set. The next
time I click the element, the coordinates from the first click have
been saved. Because there are multiple clickable elements on the page,
the effect is that the popup window is always opening at the previous
cursor position rather than the current position.

It seems like my document.onclick event handler is being called after
the onClick handler defined for the particular HTML element.

Can anyone provide info on how I can detect the current cursor position
before the element-specific onClick handler executes?
Thanks!

-Dave H.

Jul 23 '05 #1
1 10080
Dave Hammond wrote:
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 installed a
document.onclick event handler which saves the eventX and eventY
values, then use those values to set the window top/left coordinates.


Have a read of:
<URL:http://evolt.org/article/Mission_Impossible_mouse_position/17/23335/index.html>

and:

<URL:http://www.quirksmode.org/index.html?/js/events_compinfo.html>

--
Fred
Jul 23 '05 #2

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

Similar topics

3
7434
by: Helmut | last post by:
Hi! I want to show a popup table just left-above my corsor. The following code works fine (on IE), but if there are scrollbars at the browser the popup is not positionend correctly: ...
10
18038
by: Danny | last post by:
How can I get the coordinates of the mouse cursor in Mozilla browsers as well as Opera and IE6? I'm struggling to understand how to capture mouse movement events with Mozilla/Netscape/Firefox and...
4
14691
by: Jay | last post by:
Hi, How can I capture mouse position on Image? I found number of script capturing mouse position of the page. But I could not find anything based on image. What I want to find out is X Y...
4
13858
by: Jonne | last post by:
Hi, I haven't found anything like this anywhere with Google, so I'm posting it here, hoping one of you people knows how to do something like this. I'm trying to get the mouse coordinates in a div,...
4
1669
by: Sid S. | last post by:
How can I find the absolute cursor location? Where the mouse cursor is located with repect to the body. This way I can position an div tag where the mouse is, even if scrolled down farther on the...
1
11943
by: jobs | last post by:
I'm trying to understand this and don't get it... I found some code that looks like it's going to work if I can make sense of how to position the div. The code displays a div with some data...
2
2473
by: ismailc | last post by:
Hi, I need help please! Onmouseover it calls a function, but onmouseover the image it changes the cursor from default ot busy the whole time. I want it to stay to default. I have set it o...
2
1649
by: ton | last post by:
Hi I'm using this function: function getPosition(e) { e = e || window.event; curs = {x:0, y:0}; if (e.pageX || e.pageY) {curs.x = e.pageX; curs.y = e.pageY; } else
3
1697
by: Wuggles | last post by:
Hi guys, I want to use a Curser position function with javascript like this: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled...
0
7265
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,...
0
7545
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...
1
7111
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...
0
7539
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...
0
4751
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...
0
3240
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...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
461
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...

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.