473,748 Members | 5,232 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

finding position of a mouse click, using Mozilla

I have this
<DIV id="canopy" onClick="myhand ler(event.x,eve nt.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 6467
Nick Wedd napisał(a):
I have this
<DIV id="canopy" onClick="myhand ler(event.x,eve nt.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********@new s.home.net.pl>, Tomasz Cenian <aa*@bb.cc.dd >
writes
Nick Wedd napisa0 >> I have this
<DIV id="canopy" onClick="myhand ler(event.x,eve nt.y); return false;">
<IMG border=0 height=66 width=292 src="gifs/top.gif">
</DIV>


You surely missed
event.client X, 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="myhand ler(event.x,eve nt.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.h tml#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
2890
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 works well for all the pages except the 4 pages which can be opened by click the menu link in the popup. In these four pages, the popup will always be shown at the leftmost of its parent div (flow) instead of under the 'Portfolio' menu item. When...
20
17044
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. The others are free to go over ... (I already found that part) -> http://users.pandora.be/hebbrecht/jochen/c++/test.cpp
8
2052
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 works well for all the pages except the 4 pages which can be opened by click the menu link in the popup. In these four pages, the popup will always be shown at the leftmost of its parent div (flow) instead of under the 'Portfolio' menu item. When...
4
14727
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 coordinates of mouse position. based on left of the top of my image is 0 0 (X Y coordinates) otherwise, I need to find out position of my image so I can calculate.
9
5947
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
1762
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
10189
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 that direction by a fixed value. Has anyone implemented something like this before? I haven't found anything on codeproject, or searching the .NET newsgroups. This seems like it would be a common control type, am I missing the easy solution? I...
19
5942
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 the page but I find that the iframes interfere with the getting the mouse coords from the screen which is essential in moving the scroll bar around. My test html is given below. With the iframe hidden the mouse coords are obtainable. With the...
5
1747
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 help is fine for me thanks
1
9325
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
9249
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
8244
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...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
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
4607
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
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
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
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.