473,395 Members | 1,454 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.

not working both on IE and Mozilla

Expand|Select|Wrap|Line Numbers
  1. document.onclick = getcoordinate;
  2.  
  3. var mosX = 0;
  4. var mosY = 0;
  5.  
  6. function getcoordinate(e)
  7. {        
  8.     if (!e) var e = window.event;
  9.  
  10.     mosX = e.clientX + document.body.scrollLeft;
  11.     mosY = e.clientY + document.body.scrollTop;
  12.  
  13.     return true;
  14. }
  15.  
-----

<body onclick="getcoordinate()">

-----

i'm trying this code to get mouse coordinates.

for 2 days i have read too many forum posts but could not succeed ....

this code works on IE but in Mozilla it does not work..

do i miss something?
Feb 11 '08 #1
3 1566
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

See this link - it should give you an idea about how to get the co-ordinates across all browsers.
Feb 11 '08 #2
Expand|Select|Wrap|Line Numbers
  1. function doSomething(e) {
  2.     var posx = 0;
  3.     var posy = 0;
  4.     if (!e) var e = window.event;
  5.     if (e.pageX || e.pageY)     {
  6.         posx = e.pageX;
  7.         posy = e.pageY;
  8.     }
  9.     else if (e.clientX || e.clientY)     {
  10.         posx = e.clientX + document.body.scrollLeft
  11.             + document.documentElement.scrollLeft;
  12.         posy = e.clientY + document.body.scrollTop
  13.             + document.documentElement.scrollTop;
  14.     }
  15.     // posx and posy contain the mouse position relative to the document
  16.     // Do something with this information
  17. }
  18.  
  19.  
the link has this function i change it a little

Expand|Select|Wrap|Line Numbers
  1. var mosX = 0;
  2. var mosY = 0;
  3.  
  4. function getcoordinate(e)
  5. {    
  6.     if (!e) var e = window.event;
  7.  
  8.     if (e.pageX || e.pageY)     
  9.     {
  10.         mosx = e.pageX;
  11.         mosy = e.pageY;
  12.     }
  13.     else if (e.clientX || e.clientY)     
  14.     {
  15.         mosx = e.clientX + document.body.scrollLeft
  16.             + document.documentElement.scrollLeft;
  17.         mosy = e.clientY + document.body.scrollTop
  18.             + document.documentElement.scrollTop;
  19.     }
  20. }
but it must work but still does not work in mozilla
and the positons in explorer alittle changed

is this about mozilla
Feb 14 '08 #3
acoder
16,027 Expert Mod 8TB
JavaScript is case-sensitive: mosx and mosy should be mosX and mosY.
Feb 14 '08 #4

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

Similar topics

8
by: Gregory Piñero | last post by:
Hi guys, I'm trying to run this statement: os.system(r'"C:\Program Files\Mozilla Firefox\firefox.exe"' + ' "www.blendedtechnologies.com"') The goal is to have firefox open to that website....
2
by: wylbur37 | last post by:
I normally use Mozilla 1.4 on Windows XP Pro. As I was developing some test webpages, I discovered that the SRC parameter doesn't seem to work when a path is used with the filename. In one...
2
by: David | last post by:
After getting some help working through my bugs, I have what seems to be a robust, working word counter script. I post it here to benefit others that might want this in the future and so that if I...
10
by: Markus Ernst | last post by:
Hi I have a strange problem with vertical-align. The case can be viewed at http://www.brainput.info/geschichte.html. HTML code: <div id="bild"><img src="geschichte.gif" width="274"...
2
by: schieco | last post by:
The following code always prints the debug lines inside the conditional if statement before and after the alert statement when the session has timed out, but the alert and redirect only appear/work...
8
by: lawrence | last post by:
I'm a beginner with Javascript and especially cross-browser Javascript. I got this working in IE, but not in Netscape 7. It seems like, in Netscape, every time I click on a button, the focus shifts...
3
by: Eli | last post by:
Hello all, I have just added a small piece of JavaScript code to a basic HTML page of mine. At the end of the page (after the closing </HTML>) I added: <SCRIPT LANGUAGE="JavaScript">...
49
by: Atul Chaturvedi | last post by:
If we use ASP.NET 2.0 Login Control, we are unable to click on Login and Reset Buttons on Safari running on Apple Mac OS X Version 10.3.2 . How can i resolve the problem.
1
by: ajaysoniji | last post by:
Hi, I am using this code to read the option values from a select option. I am getting the reference of that select option in arg1. Its working fine with mozilla firefox but not with Internet...
6
pravinda
by: pravinda | last post by:
Hi, I got a problem please check http://www.technocreative.com/ both in the iexplore and mozilla(firefox). it is working well in explore but problem in mozilla i am get big problem so please do...
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: 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
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
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
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.