I have some code that checks a condition of where the mouse is, and then if it’s true it creates an alert and then redirects.
It works fine, but if you right click somewhere and then left click in an area that gives the condition a true, then it alerts, you click ok, and then it alerts again, you click ok, and then it redirects.
I only want it to alert once and then to redirect.
$(document).ready(function(){
…
$(document).bind('mousemove', function(e){
…
if(20 > e.pageX)){
alert("You did it!");
window.location.href = "http://www.google.com";
}
}
}
Unbind mousemove. mousemove will fire on mouse move so it can be multiple times call your function in minor mouse move. to prevent it unbind event once it work done
}