Hi, I'm currently doing on a project, frankly speaking i'm new in javascript only know the basics. I'm not even sure whether this thread is suppose to be here or under html..
I'm suppose to create some codes that enable a html page to load to the next html page when the mouse move from left to right within a specific time and distance(positive X coordinate) and also the other way round (right to left) once i figured out this. I've got an example online and edited it. Please take a look at my codes.
<BODY onLoad="setTimeout('getMouseXY(e)', 3000)">
<form name="Show">
X : <input type="text" name="MouseX" value="0" size="4"><br/>
Y : <input type="text" name="MouseY" value="0" size="4"><br/>
<br/>
deltaX : <input type="text" name="DeltaX" value="0" size="4"><br/>
deltaY : <input type="text" name="DeltaY" value="0" size="4"><br/>
<br/>
PageUp : <input type="text" name="PageUp" value="0" size="4"><br/>
</form>
<script language="JavaScript">
<!-- Begin
var deltaX=0;
var deltaY=0;
var oldX=0;
var oldY=0;
var pageUp=0;
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
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;
}
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}
document.Show.MouseX.value = tempX;
document.Show.MouseY.value = tempY;
if (oldX != tempX){
deltaX = tempX - oldX;
oldX = tempX;
}
if (oldY != tempY){
deltaY = tempY - oldY;
oldY = tempY;
}
document.Show.DeltaX.value = deltaX;
document.Show.DeltaY.value = deltaY;
if (deltaX>300){
pageUp++;
deltaX=0;
window.location = "test01.html"// loads to next page
}
document.Show.PageUp.value = pageUp;
return true;
}
// End -->
</script>
test01.html is just blank page created to make sure it loads. However i would like to load from test01 to another html page but no matter how i tried to edit the codes, there's errors. I cant possibly copying and pasting the exact codes to every page i want to load to right?
And is it possible to sortof increase mouse sentivity such that i can most probably load to the next page in first few tries of moving the mouse on the first page.
Is it common that when i launch the html on IE and Firefox somehow after showing the first page for maybe 1 second, it immediately jumped to 2nd page and i have to go back to 1st page to try out.
So sorry for asking so much from here. thanks in advance for any help(((: