Solved

Catch Cursor position ?

Posted on 2002-05-02
2
166 Views
Last Modified: 2012-08-13
I have couple links on the page.
All links will go to a javascript function that will
alert current cursor x and y position.

How to do that ?
0
Comment
Question by:tanc02
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
ckosloski earned 100 total points
ID: 6986539
See if this is what you want.

<html>
<head>
<script>
function ShowMousePosition(event)
{
   if(document.all)
   {
      xpos = event.x;
      ypos = event.y;
   }
   else if(document.layers || (!document.all && document.getElementById))
   {
      xpos = event.pageX;
      ypos = event.pageY;
   }
   alert("x=" + xpos +"\ny=" + ypos);
}
</script>
</head>
<body>
<a href="#" onClick="ShowMousePosition(event);">Link 1</a>
<br><br><br>
<a href="#" onClick="ShowMousePosition(event);">Link 2</a>&nbsp;<a href="#" onClick="ShowMousePosition(event)";>Link 3</a>
</body>
</html>

Corey
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 6986581
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Simple Ticker</title>
<script language=javascript>
function test(){
     alert(document.body.scrollLeft+event.clientX +"--"+ document.body.scrollLeft+event.clientY);
}
</script>
</head>
<body>
<div style="width:500;height:500;background:yellow;" onclick="test()">

</body></html>

T.P.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question