...

View Full Version : Implement a tmer into js function



alexistkd
02-21-2011, 01:06 PM
Hi i have already this function im trying to add a timer like this: when value >= 1 and user doesnt move mouse for 1 minute or 60 seconds timer starts and redirect user to a new page but if user moves mouse before 60 seconds end the timer resets again.


function pagar(){
var textarea = document.getElementById ("textarea");
/*if (event.propertyName.toLowerCase () == "value") {
alert ("NUEVO VALOR EN EL CAMPO TOTAL: " + event.srcElement.value);
}*/
if (event.srcElement.value>=1)
{
var bottomMenu = $("#main_footer").bottomMenu([
{name:"backward","class":"red", text:getStr("menu_backward")},
{name:"menu","class":"green", text:getStr("menu_menu"), func:function(){parent.location = "./index.html";}, enabled:false},
{name:"forward","class":"green", text:getStr("menu_pay"), func:forward, enabled:true}
]);
}
else
{
var bottomMenu = $("#main_footer").bottomMenu([
{name:"backward","class":"red", text:getStr("menu_backward")},
{name:"menu","class":"green", text:getStr("menu_menu"), func:function() {parent.location = "./index.html";}, enabled:true},
{name:"forward","class":"green", text:getStr("menu_pay"), func:forward, enabled:false}
]);
}
}


want to add a timer after this


if (event.srcElement.value>=1)
{


of course if value ist >=1 timer doesnt start.

Thanks in advance.

Fumigator
02-25-2011, 09:44 PM
You're using jQuery I guess? You can use the timers plugin alongside the .mousemove() event to reset a timer every time the mouse moves. If this timer gets to 0 you know the mouse didn't move for the duration of the timer.

Get the timers plugin here:

http://jquery.offput.ca/every/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum