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
a) This javascript function will return current mouse cursor position in the browser window.
b) 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)
c) Function getXY() gets the x and y axis values on cursor position in the browser window size.
d) Just copy the code in to your page and enjoy the effect.
Preview
Code
Code:
<!-- Script by hscripts.com -->
<!-- copyright of HIOX INDIA -->
<!-- more scripts @ http://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 -->
a) Copy the javascript code into <head> tag of your page.
b) Create the HTML with the same form fields.
<form name=ee>
<input name=sd type=text>
</form>
c) The function getXY(e) will be invoked whenever there is a change in cursor positioning.
d) Add your code under the comment to fit your requirement.
- The javascript (misspelled as java script) is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Click Here for detailed license information.
- You can purchase the script if your requirements does not meet our GPL License terms.