I hope this makes some sense. My ultimate goal here is to execute a block of code if the mouse has not moved in a minute or so within the broswer. The machine I am running this on is for internal use only, so I have no fear of this not working in certain browsers, etc.
I am no javascript pro but know enough to catch on if anyone is kind enough to help me out here. One of the only ways I could see this working is by having js check the mouse coordinates and compare them to see if they have changed or not. I dont know if this is an absurd way to go about or not, but I could see it working. So I have this so far, it just shows the x and y coordiantes...
I know the following is not correct at all, but I was just sketching the idea out in notepad for how the logic could work.
I dont even know if that is decipherable or even close to the correct syntax? But my MAIN question is this.. If someone can help me with this, I am pretty certain I can make this work.
How would I "capture" the tempX and tempY variables and store them in say, var Capture1 and then 5 seconds later "capture" tempX and tempY again, and store those values in say, var Capture2? If I can grab the coordinates at a given time I can then compare them. If the coordiantes stay the same for about 10 loops thorough that code, then my next block of code could be run.
... It is late.... I hope this makes sense, and I would be SUPER happy if someone could help me out, or at least point me somewhere.
Thanks a ton for any help!
I am no javascript pro but know enough to catch on if anyone is kind enough to help me out here. One of the only ways I could see this working is by having js check the mouse coordinates and compare them to see if they have changed or not. I dont know if this is an absurd way to go about or not, but I could see it working. So I have this so far, it just shows the x and y coordiantes...
Code:
<!--
============================================================
Capturing The Mouse Position in IE4-6 & NS4-6
(C) 2000 www.CodeLifter.com
Free for all users, but leave in this header
//-->
<html>
<body>
<!-- Part One:
Set up a form named "Show" with text fields named "MouseX"
and "MouseY". Note in the getMouseXY() function how fields
are addressed, thus: document.FormName.FieldName.value
//-->
<form name="Show">
<input type="text" name="MouseX" value="0" size="4"> X<br>
<input type="text" name="MouseY" value="0" size="4"> Y<br>
</form>
<!-- Part Two:
Use JavaScript ver 1.2 so older browsers ignore the script.
The <script> must be *after* the <form> -- since the form
and fields must exist *prior* to being called in the script.
//-->
<script language="JavaScript1.2">
<!--
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false
// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)
// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft
tempY = event.clientY + document.body.scrollTop
} else { // grab the x-y pos.s if browser is NS
tempX = e.pageX
tempY = e.pageY
}
// catch possible negative values in NS4
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}
// show the position values in the form named Show
// in the text fields named MouseX and MouseY
document.Show.MouseX.value = tempX
document.Show.MouseY.value = tempY
return true
}
//-->
</script>
</body>
</html>
Code:
counter = 0
if counter < 20
{
if tempxy == grabxy
set storexy cord
wait 5 seconds
if storexy == tempxy
counter = counter ++
}
else
//code to go here
How would I "capture" the tempX and tempY variables and store them in say, var Capture1 and then 5 seconds later "capture" tempX and tempY again, and store those values in say, var Capture2? If I can grab the coordinates at a given time I can then compare them. If the coordiantes stay the same for about 10 loops thorough that code, then my next block of code could be run.
... It is late.... I hope this makes sense, and I would be SUPER happy if someone could help me out, or at least point me somewhere.
Thanks a ton for any help!
Comment