Hi All,
Just wondering if its possible to get the x/y location of the mouse from the onload event of the document (before any mousemove events).
Thanks
Guido
Hi All,
Just wondering if its possible to get the x/y location of the mouse from the onload event of the document (before any mousemove events).
Thanks
Guido
short answer: no
long answer: yes. the onload event doesn't provide info on the mouse position, however you can set a variable when onload has fired, and use the onmousemove event on the document to get the mouseposition as soon as the mouse moves after the documents loads (after the variable has been set). Not what you wanted, though.
You can try something like:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script type="text/javascript">
function SetValues() {
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
getMouseXY();
var mX = 0;
var mY = 0;
function getMouseXY(e) {
if (IE) {
mX = event.clientX + document.body.scrollLeft;
mY = event.clientY + document.body.scrollTop;
}
else {
mX = e.pageX;
mY = e.pageY;
}
var s = 'X=' + mX + ' Y=' + mY ;
document.getElementById('divCoord').innerHTML = s;
return true;
}
}
</script></head>
<body onload=SetValues()>
<div id="divCoord"></div>
</body></html>