Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

How to Get Mouse Coordinates with Javascript

Posted by Viral Sarvaiya on October 29, 2009

This will find X and Y coordinates of the mouse where the mouse moves in browser.

<title>Get Mouse Coordinates</title>
<script language="javascript">
var divObj;


function getMouseCoordinates(event)
ev = event || window.event;
divObj.innerHTML = "Mouse X:"+ev.pageX + " Mouse Y:"+ev.pageY;

function loadDiv()
divObj = document.getElementById("mouseCoord");

<body onLoad="loadDiv()">
<div id="mouseCoord">Mouse Coordinates position will be displayed here.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: