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

finding position of a mouse click, using Mozilla

I have this
<DIV id="canopy" onClick="myhandler(event.x,event.y); return false;">
<IMG border=0 height=66 width=292 src="gifs/top.gif">
</DIV>
which works in IE. myhandler gets called with the coordinates of where
the mouse was clicked relative to the <HTML>, and I know where my DIV
is, so I can calculate which part of the image was clicked on.

But with Mozilla, I can't use event.x and event.y, only event.screenX
and event.screenY. These are relative to the whole screen, and so are
affected by the positioning of the browser window and the amount of
browser chrome, so I can't translate them to the frame of my image.

Is there a simple way to deal with this? A Google search leads me to
pages like http://www.mozilla.org/docs/events.html which I am not able
to understand.

The best I can come up with is to create a bunch of empty ("visible" but
transparent) layers that sit in front of my "canopy" layer and catch the
mouse clicks.

Nick
--
Nick Wedd ni**@maproom.co.uk
Jul 23 '05 #1
3 6434
Nick Wedd napisaƂ(a):
I have this
<DIV id="canopy" onClick="myhandler(event.x,event.y); return false;">
<IMG border=0 height=66 width=292 src="gifs/top.gif">
</DIV>


You surely missed
event.clientX, event.clientY.

Do not use event.x - its obsolete and IE only.
--
tomasz cenian tcenian at wa dot home dot pl
:::: :: : : http://cenian.boo.pl : : :: ::::
Jul 23 '05 #2
In message <42********@news.home.net.pl>, Tomasz Cenian <aa*@bb.cc.dd>
writes
Nick Wedd napisa0 >> I have this
<DIV id="canopy" onClick="myhandler(event.x,event.y); return false;">
<IMG border=0 height=66 width=292 src="gifs/top.gif">
</DIV>


You surely missed
event.clientX, event.clientY.

Do not use event.x - its obsolete and IE only.


Great! Thanks very much for the advice.

Nick
--
Nick Wedd ni**@maproom.co.uk
Jul 23 '05 #3
Nick Wedd wrote:
I have this
<DIV id="canopy" onClick="myhandler(event.x,event.y); return false;">
<IMG border=0 height=66 width=292 src="gifs/top.gif">
</DIV>
which works in IE. myhandler gets called with the coordinates of where
the mouse was clicked relative to the <HTML>, and I know where my DIV
is, so I can calculate which part of the image was clicked on.

But with Mozilla, I can't use event.x and event.y, only event.screenX
and event.screenY. These are relative to the whole screen, and so are
affected by the positioning of the browser window and the amount of
browser chrome, so I can't translate them to the frame of my image.

Is there a simple way to deal with this? A Google search leads me to
pages like http://www.mozilla.org/docs/events.html which I am not able
to understand.


The section of the Mozilla site you were after is:

*DOM Reference*:
<URL:http://www.mozilla.org/docs/dom/domref/>

*Event Reference*

<URL:http://www.mozilla.org/docs/dom/domref/dom_event_ref.html#998197>

Where you will find references to W3C DOM properties clientX/Y
and screenX/Y and the older, non-W3C layerX/Y, pageX/Y.

If you are doing stuff with coordinates, the "Viewport" link at
quirksmode.org is an invaluable reference:

<URL:http://www.quirksmode.org/index.html>
--
Rob
Jul 23 '05 #4

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

Similar topics

1
by: nick | last post by:
In the web site http://greywolfdesign.com , there is a pop-up menu (when mouse over 'Portfolio' menu item), it always works well when using IE (6). However, when using Mozilla 1.6, the popup...
20
by: Webdad | last post by:
Hi! I running my first year as industrial engineer (informatics) We have an assignment to do : .... create a playfield (matrix). Some places in that field are blocked, so you can't pass them....
8
by: nick | last post by:
In the web site http://greywolfdesign.com , there is a pop-up menu (when mouse over 'Portfolio' menu item), it always works well when using IE (6). However, when using Mozilla 1.6, the popup...
4
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...
9
by: Samantha | last post by:
Looking at the goto(xy) thread. Is there a way to get the X,Y position from a cursor click and then use the position to apply something like a water mark on an image at that position? Thanks,
8
by: nescio | last post by:
hello, i have a script that finds the x and y from the mouse position, this works fine. but now i have an image in a layer : <div id='someLayer'> <img src='someImage.jpg'> </div>
2
by: mmdst23 | last post by:
I'm working on a video player app, and I want to implement a trackbar that behaves like the one in Media Player, that is the cursor position moves to where the user clicked instead of moving in...
19
by: wmanzo | last post by:
I have a really professional conspiracy movie site and I use tons of layers and an external scroll bar assembly. I would like to put the various sections into MS Iframes and in order to clean up...
5
by: sagar | last post by:
is there any way to find the position of mouse click on a form actually the problem is i m having more than one controls on a form i want to find which control is selected using mouse down any...
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: 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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.