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

Mouse position error

Hi guys,
I want to use a Curser position function with javascript like this:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Untitled Document</title>
  5. <script language="javascript">
  6. function test(){
  7.     var posx = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
  8.     var posy = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
  9.     alert(posx+","+posy);
  10. }
  11.       </script>
  12. </head>
  13.  
  14. <body>
  15. <input name="test" type="button" value="click me" onClick="test();"/>
  16. </body>
  17. </html>
  18.  
This isn't the problem, this'll work. But when I include the javascript file Prototype.js it won't work anymore, an error will show.
The error is 'variable e is not defined'
this code won't work:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Untitled Document</title>
  5.  
  6. <script src="js/prototype.js" type="text/javascript"></script>
  7.  
  8. <script language="javascript">
  9. function test(){
  10.     var posx = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
  11.     var posy = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
  12.     alert(posx+","+posy);
  13. }
  14.       </script>
  15. </head>
  16.  
  17. <body>
  18. <input name="test" type="button" value="click me" onClick="test();"/>
  19. </body>
  20. </html>
  21.  
(I'm using Prototype 1.5.0 btw)
Can anyone help me? I really need the Javascript Framework and the mousepos function working.
Jan 23 '09 #1
3 1690
Dormilich
8,658 Expert Mod 8TB
does the error console (firefox) show any errors? (alternately, you could provide a link, so that we can see for ourselves)
Jan 23 '09 #2
@Dormilich
Yeah the error console says 'e is not defined' same as I.E.

By the way, this is without prototype:
Untitled Document
and this is with the prototype:
Untitled Document
Jan 24 '09 #3
Problem fixed :)
'Event' was supposed to be 'event'.
Jan 24 '09 #4

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

Similar topics

9
by: punkin | last post by:
I am trying to catch mouse position on the entire screen by dynamically generating mouse click event at every 100 ms. My code only works for IEs but not any Netscape or Gecko-based browsers. The...
5
by: gsb | last post by:
I track the mouse location like this code: function mousePos(e) { var p = new Object(); if(e) { p.x = e.pageX; p.y = e.pageY; } else { p.x = event.x; p.y = event.y; } ... (show) }...
6
by: lauren quantrell | last post by:
I have a command button on a continuous subform and I want the user to click it to open a small popup form that opens in the position of the mouse (which is the same as the position of the command...
2
by: Hendrik | last post by:
Hi I have searched extensively for help on inserting text at the position of the mouse pointer in a text box as the final step of drag and drop process What I have come with is listed below - the...
3
by: Emjay | last post by:
Newbie needs to know how to set the mouse position.
3
by: jcrouse | last post by:
I have created a form designer type application (with a lot of you peoples helpJ). It has label controls that are draggable at runtime. The user is also allowed to change some properties such as...
13
by: Lars Netzel | last post by:
Hi! I have a round area which I want to be able to move the mouse over and fire off events... how do I do that? I have drawn a FillPie Graphics and I feel that there has to be a way of...
2
by: romain.larmet | last post by:
Hi all, I need to get the mouse cursor's position using JavaScript. Until now, everything was working well in IE, FF and Opera using the event.clientX/Y and e.pageX/Y members, depending on which...
2
by: markszlazak | last post by:
In the following script, a control displays (black box) in each table cell once you mouse over the cell. Mouse down on the control to change the mode of the table. Drag the mouse over cells in the...
4
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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
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.