»
EnglishFrenchVietnamese

Print - Stop the Clock! - JavaScriptBank.com

Full version: jsB@nk » Game » Stop the Clock!
URL: http://www.javascriptbank.com/stop-the-clock.html

Stop the Clock! © JavaScriptBank.comTest your reflexes. The object is to stop the counter as close to 500 as possible. The lower your score, the better. Can you get a score of 0?

Full version: jsB@nk » Game » Stop the Clock!
URL: http://www.javascriptbank.com/stop-the-clock.html



JavaScript
<script type="text/javascript">// Created by: Kurtis Dinelle :: http://www.spamburger.netplaying=false;function startClock(){  if(playing==false) {    the_time=setInterval('document.game.timer.value++',1);  }  playing=true;}function stopClock() {  // You can change the two numbers ("500") below to a different value.  score=Math.abs(document.game.timer.value-500);  if(playing==true&&score<500) {    clearInterval(the_time);    alert('Your score is '+score+'.');    playing=false;    if(score==0) {      alert('Woo hoo! Perfect Score!');    }  document.game.timer.value=0;  }}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name="game">  <input readonly type="text" name="timer" size="3" value="0">  <br><br>  <input type="button" value="Start" onclick="startClock()">  <input type="button" value="Stop" onclick="stopClock()"></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->