HTML and JavaScript Code to Simulate the Clock which displays System Time.
HTML "Hyper Text Markup Language" is the language which is responsible to display the Text in Web-browsers with various form and effects. All HTML code is enclosed in <html></html> tags. While JavaScript is client side object based language whose code executes at Client side. This language is useful in form field validations , calculations etc and also in the situation when data is not required to submit to the Web Server.
<html>
<head>
<title> JavaScript Timer Demo </title>
<script language="javascript" type="text/javascript">
function startTime()
{
var today= new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
m=checkTime(m);
s=checkTime(s);
document.getElementById("txtTi
t=setTimeout("startTime()",500
}
function checkTime(i)
{
if(i<10)
{
i="0"+i;
return i;
}
return i;
}
</script>
</head>
<body onLoad="startTime()">
<div id="txtTime">
</div>
</body>
0 comments:
Post a Comment