I want to use a Curser position function with javascript like this:
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- <script language="javascript">
- function test(){
- var posx = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
- var posy = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
- alert(posx+","+posy);
- }
- </script>
- </head>
- <body>
- <input name="test" type="button" value="click me" onClick="test();"/>
- </body>
- </html>
The error is 'variable e is not defined'
this code won't work:
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- <script src="js/prototype.js" type="text/javascript"></script>
- <script language="javascript">
- function test(){
- var posx = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
- var posy = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
- alert(posx+","+posy);
- }
- </script>
- </head>
- <body>
- <input name="test" type="button" value="click me" onClick="test();"/>
- </body>
- </html>
Can anyone help me? I really need the Javascript Framework and the mousepos function working.