Forum Moderators: open
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>assignment 6</title>
<style type="text/css">
body {
color:#000;
background-color:#fff;
}
a {
color:#00f;
}
a:visited {
color:#800080;
}
a:hover {
color:#008000;
}
a:active {
color:#f00;
}
#gameContainer {
width:50%;
height:200px;
border:1px solid #000;
margin:auto;
}
#button{
margin:5px 0 0 20%;
margin-top:5px;
float:left;
}
#statsBox {
padding:10px;
border:1px solid #000;
margin:5px 0 0 10%;
float:left;
}
#statsBox div {
margin:6px;
}
</style>
<script type="text/javascript">
function clock(){
if(time>0){
time--;
if(time<10){
time='0'+time;
}
document.getElementById('time').innerHTML=time;
}
else {
clearTimeout(t);
play=false;
return;
}
t=setTimeout(function(){clock()},1000)
}
function buttonPress() {
alert('this is working OK');
}
function init(){
time=30;
document.getElementById('button').onclick=function() {
buttonPress();
}
document.getElementById('play').onclick=function() {
clock();
}
}
window.addEventListener?
window.addEventListener('load',init,false):
window.attachEvent('onload',init);
</script>
</head>
<body>
<div id="gameContainer">
<button id="button">Click Me!</button>
<div id="statsBox">
<div>Time:<span id="time">30</span></div>
<div>Score:<span id="score">0</span></div>
<div>High Score:<span id="highScore">0</span></div>
<div><button id="play">play!</button></div>
</div>
</div>
</body>
</html>
var t = setInterval(function() { clock(time, play);}, 1000);
function clock() {
if (time > 0) {
time--;
document.getElementById("time").innerHTML = time;
return time;
}
else{
clearInterval(t);
play = false;
return;
}
}
var t = setInterval(function() { clock(time, play);}, 1000);
var t = setInterval(clock, 1000);
clearInterval(t);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>assignment 6</title>
<style>
body {
color:#000;
background-color:#fff;
}
a {
color:#00f;
}
a:visited {
color:#800080;
}
a:hover {
color:#008000;
}
a:active {
color:#f00;
}
#gameContainer {
width:50%;
height:200px;
border:1px solid #000;
margin:auto;
}
#button{
margin:5px 0 0 20%;
margin-top:5px;
float:left;
}
#statsBox {
padding:10px;
border:1px solid #000;
margin:5px 0 0 10%;
float:left;
}
#statsBox div {
margin:6px;
}
</style>
<script>
function clock(){
if(time>0){
time--;
if(time<10){
time='0'+time;
}
document.getElementById('time').innerHTML=time;
}
else {
clearTimeout(t);
play=false;
return;
}
t=setTimeout(function(){clock()},1000)
}
function buttonPress() {
alert('this is working OK');
}
function init(){
time=30;
document.getElementById('button').onclick=function() {
buttonPress();
}
document.getElementById('play').onclick=function() {
clock();
}
}
window.addEventListener?
window.addEventListener('load',init,false):
window.attachEvent('onload',init);
</script>
</head>
<body>
<div id="gameContainer">
<button id="button">Click Me!</button>
<div id="statsBox">
<div>Time:<span id="time">30</span></div>
<div>Score:<span id="score">0</span></div>
<div>High Score:<span id="highScore">0</span></div>
<div><button id="play">play!</button></div>
</div>
</div>
</body>
</html>