Browser window Mouse Cursor Position

This is a javascript function that will return the current cursor position on the browser window. This java script can be used in any html page.


  • This javascript function will return current mouse cursor position in the browser window.
  • We use two functions to get the result. The function init() is used to initialize event handler and capture mouse events in IE (Internet Explorer) and Mozilla (netscape).
  • Function getXY() gets the x and y axis values on cursor position in the browser window size.
  • Just copy the code in to your page and enjoy the effect.




<!--Script by>
<!-- more scripts @ -->
<script type="text/javascript">
window.onload = init;
function init() {
if (window.Event) {
document.onmousemove = getXY;
function getXY(e) {
x = (window.Event) ? e.pageX : event.clientX;
y = (window.Event) ? e.pageY : event.clientY; = x+":"+y;
<!-- Script by -->
  • Release Date - 18-07-2005
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to


  • Copy the javascript code into
  • <head> tag of your page.
  • Create the HTML with the same form fields.
  • <form name=ee>
       <input name=sd type=text>
  • The function getXY(e) will be invoked whenever there is a change in cursor positioning.
  • Add your code under the comment to fit your requirement.


Related Scripts

Free Javascript Scripts

Ask Questions

Ask Question