Solved

Catch Cursor position ?

Posted on 2002-05-02
2
160 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
2 Comments
 
LVL 4

Accepted Solution

by:
ckosloski earned 100 total points
Comment Utility
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
Comment Utility
<!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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Tag input html 4 35
.removeAttr() not working in my SharePoint JSOM code 8 35
jqplot Pie Chart 2 11
Problem to page 4 16
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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 …
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now