Jak zrobisz w js to możesz dodatkowo pokazywać czas do końca.
A po upływie czasu uruchomic jakiś popup, czy alert z wynikiem.
Kod
var running = false
var endTime = null
var timerID = null
function startTimer() {
running = true
now = new Date()
now = now.getTime()
// ostatni czynnik oznacza liczbę minut
endTime = now + (1000 * 60 * 1)
showCountDown()
}
function showCountDown() {
var now = new Date()
now = now.getTime()
if (endTime - now <= 0) {
stopTimer()
alert("Czas upłynął, twój wynik to " + score)
score=0
doc.scoreform.score.value= " 0"
startTimer()
} else {
var delta = new Date(endTime - now)
var theMin = delta.getMinutes()
var theSec = delta.getSeconds()
var theTime = theMin
theTime += ((theSec < 10) ? ":0" : ":") + theSec
document.timeform.time.value = " " + theTime
if (running) {
timerID = setTimeout("showCountDown()",1000)
}
}
}
function stopTimer() {
clearTimeout(timerID)
running = false
document.timeform.time.value = " 0:00"
}
onload="startTimer();"