29 lines
756 B
HTML
Executable File
29 lines
756 B
HTML
Executable File
<html>
|
|
<head>
|
|
<title>Example 7.14</title>
|
|
<script>
|
|
function startClock()
|
|
{
|
|
var today = new Date();
|
|
var hour = today.getHours(); var min = today.getMinutes(); var sec = today.getSeconds();
|
|
min = checkTime(min);
|
|
sec = checkTime(sec);
|
|
document.getElementById('now').innerHTML = ("Today's date: " + today);
|
|
document.getElementById('clock').innerHTML = hour + ":" + min + ":" + sec;
|
|
timer = setTimeout('startClock()',500);
|
|
}
|
|
function checkTime(i)
|
|
{
|
|
if (i<10)
|
|
i="0" + i;
|
|
return i;
|
|
}
|
|
</script>
|
|
</head>
|
|
<body><table align="center" width = "70%"><tr><td><br />
|
|
<input type ="button" onclick="startClock()" value = "Does anyone know what day it is?"><br />
|
|
<h3><span id = "now"> </span></h3>
|
|
<h3><span id = "clock"> </span></h3>
|
|
</body>
|
|
</html>
|