Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2011
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •