Step by step procedure Implementing about JavaScript Timer

Timer Demo:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head>

<title>Validation On Submit</title>

<script language=”JavaScript”>

function showClientTime() {

var dt = new Date()

spnTime.innerHTML = dt.toLocaleTimeString();

setTimeout(“showClientTime ()”, 1000);

}

</script>

</head>

<body onload=”showClientTime()”>

<span id=”spnTime”></span>

</body>

</html>

To show and close window:

<script type=”text/JavaScript”>

var win;

function ShowWindow() {

win = window.open(“JS1.htm”, “win1”, “menubar=no,scrollbars=no,width=400,height=500,location=no,resizable=yes”)

}

function CloseWindow() {

win.close();

}

</script>

ShowTime.js:

Code for displaying time

document.write(“<span id=’spnTime’></span>”)

function setClientTime() {

document.getElementById(“spnTime”).innerHTML = new Date().toTimeString();

setTimeout(“setClientTime()”, 1000)

}

setClientTime()

In any HTML Page, add the following to show System time:

<script type=”text/JavaScript” src=”ShowTime.js”></script>

 

 

Leave a Reply