[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 297
  • Last Modified:

How do I use asp.net (vb coding) to write the X Y mouse position coordinates to a server-side textfile?

I want to write the mouse position coordinates to a text file on the server as users move the cursor around. I would like to do this about 5-10 times per second via some type of appending-a-textfile method or perhaps store them in a hidden field (e.g. a hidden listbox etc) and then write them all at once to the server-side file. Anyone know how I can accomplish this? Many thanks.....

  • 2
1 Solution
This will capture the xy of the mouse onmove and will put the values in a textarea
<script language="javascript">
	function getXY()
		var t = document.getElementById("mousexy");
		var x = window.event.clientX;
		var y = window.event.clientY;
		var xy = "X: " + x + ", Y: " + y + "\n";
		t.value = t.value + xy;
<body onmousemove="getXY()">
<textarea id="mousexy" type="text" style="height:300px; width:400px;"></textarea>

Open in new window

jazjefAuthor Commented:
One note, use

pageX, pageY for Firefox.

if that is a concern.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now