Detecting Mouse Position | JavaScriptSource

Detecting Mouse Position

Roy Marchand May 30, 2007


This is an easy way to determine the mouse position on a Web page. Click anywhere on the page and the coordinates will be displayed.

You can store them in form fields

x = y =

or as plain text



Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: mousePosition.js


Paste this code into the HEAD section of your HTML document.


Paste this code into the BODY section of your HTML document

Leave a Response


It really works in all browsers i tested. Thanks! I have tried many other types of cursor position functions but this really works and it is very easy to understand and use.[br /][br /]We thank you THE JAVASCRIPT SOURCE!

Adrian May 2, 2008

Thank's[br /]Interesting for use with CSS !

lavercq Jun 2, 2007