Javascript Countdown Timer

I need a countdown timer that can display the second one: the miliseconds format, I found one that I thought I could change it to show it as 4:92, but for some reason it doesn't want to work for me. It works fine on the site, but I'm trying to put it in my page, the console tells me:

Uncaught ReferenceError: display is not defined.

What have I done wrong?

    var milisec=0 
    var seconds=30 
    document.getElementById("timer").innerHTML='30' 
    function display(){ 
        if (milisec<=0){ 
            milisec=9 
            seconds-=1 
        } 
        if (seconds<=-1){ 
            milisec=0 
            seconds+=1 
        } 
        else 
            milisec-=1 
            document.getElementById("timer").innerHTML=seconds+"."+milisec 
            setTimeout("display()",100) 
    } 
display() 

( source )

+5
source share
1 answer

setTimeout( display, 100 ), , , , fn (, , load anon literal?)

+4

All Articles