Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-21-2011, 01:06 PM   PM User | #1
alexistkd
New Coder

 
Join Date: Feb 2011
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
alexistkd is an unknown quantity at this point
Exclamation Implement a tmer into js function

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.

Code:
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

Code:
    if (event.srcElement.value>=1)
{
of course if value ist >=1 timer doesnt start.

Thanks in advance.
alexistkd is offline   Reply With Quote
Old 02-25-2011, 09:44 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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/
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:37 AM.


Advertisement
Log in to turn off these ads.