Countdown Timer that doesn't reset when you refresh the page?

后端 未结 3 974
星月不相逢
星月不相逢 2020-12-30 16:47

I Need to have a code for the timer that doesn\'t reset the countdown timer even you refresh the page.

I saw sample code at keith wood plug in, but

3条回答
  •  孤城傲影
    2020-12-30 17:06

    If you want to use that script then you'll have to count by date and not a custom countdown value in order for it not to get reset on page refresh: http://jsfiddle.net/qWERa/1/

    //Custom countdown value starting on page load
    $('#CountdownbyValue').countdown({until: '+0h +0m +8s', format: 'HMS',onExpiry: liftOff,});
    
    //Countdown by Date
    $('#CountdownbyDate').countdown({until: new Date(2012, 11-1, 17, 10, 10, 10), format: 'HMS',onExpiry: liftOff,});
    
    //Time is up dialog!
    function liftOff() {
        alert('Time is up!');
    }
    

    Full Code:

    
    
    Demo
     
    
    
    
    
    
    

    Your can also try:

    window.onbeforeunload = function() {
        return "Are you sure you want to quit this exam?";
    }
    

    I suggest you take a look at this Countdown timer with cookies

提交回复
热议问题