help with timer

Discussion in 'JavaScript' started by hollywoodtwo, Oct 11, 2008.

  1. #1
    hello members, I'm new here and would like some help ! :)


    My webpage has a 30 seconds timer which counts down to 0 and gives a result

    well the timer is known as x

    so my users don't wanna wait for it , they just cheat using the following code :

    javascript:var x=1

    :mad: , is there anyway to prevent that from happening ?

    i hope you help me as fast as possible , this is really urgent .

    Thanks
     
    hollywoodtwo, Oct 11, 2008 IP
  2. bobbym

    bobbym Well-Known Member

    Messages:
    1,007
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    128
    #2
    Welcome to DP, I hope there will be someone could help you with that. be patient.
     
    bobbym, Oct 11, 2008 IP
  3. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #3
    use setTimeout or a framework like mootools or jquery. do this as an anonymous function on a delay
    
    // via mootools it would go...
    (function() {
    // code to run here after 30 seconds elapse.
    }).delay(30000);
    
    // via vanilla js it can be as:
    setTimeout(30000, function() {
    // what to run after it expires.
    });
    
    PHP:
    unless you reference this as var timeController = setTimeout, even clearTimeout (or $clear in mootools) won't be able to stop the event or speed it up.
    make sure you leave the function as anonymous here and don't do something like:

    
    function showResults() {
    ...
    }
    
    setTimeout(30000, showResults);
    
    PHP:
    else, they can do javascript:showResults() instead of owning your timer.
     
    dimitar christoff, Oct 11, 2008 IP
  4. djzmo

    djzmo Active Member

    Messages:
    165
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Lol.
    I guess you're owning a PTC site using YourOwnBux XD. I fixed it in my PTC btw.
     
    djzmo, Oct 11, 2008 IP
  5. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    wtf?

    .....
     
    MMJ, Oct 12, 2008 IP