Set the mouse position...
I want to set the mouse position in my webpage with the following code (IE version) :
but it doesn't work (script error). I saw in the MSDN doc that properties 'x' and 'y' enable to set or retrieve the mouse position.
Does someone know a tip to help me ?
Thanks for any answer...
Last edited by David.V; 07-09-2004 at 06:44 AM.
You cannot move the mouse. The x and y represent where the mouse was when the event occurred. You can write to those values, but it will not move the mouse.
Here's a cross-browsers solution:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
// capture the mouse position
var posx = 0;
var posy = 0;
if (!e) var e = window.event;
if (e.pageX || e.pageY)
posx = e.pageX;
posy = e.pageY;
else if (e.clientX || e.clientY)
posx = e.clientX;
posy = e.clientY;
document.getElementById('pos').innerHTML = 'Mouse position is: X='+posx+' Y='+posy;
eeerr, yes... you wrote set, I was not attentive and understood get the mouse position. gil davis may be right, I think you may not move the mouse...
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)