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.

Features

  • 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.

Preview

Downloads

Javascript

<!--Script by hscripts.com-->
<!-- more scripts @ https://www.hscripts.com -->
<script type="text/javascript">
window.onload = init;
function init() {
if (window.Event) {
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = getXY;
}
function getXY(e) {
x = (window.Event) ? e.pageX : event.clientX;
y = (window.Event) ? e.pageY : event.clientY;
document.ee.sd.value = x+":"+y;
}
</script>
<!-- Script by hscripts.com -->
  • 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 support@hscripts.com

Usage

  • 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>
       </form>
  • 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.

License

Related Scripts

Free Javascript Scripts


Ask Questions

Ask Question