Wednesday, 19 September 2012

Timer Using Java Script

We use timer control in VB6.0 ,VB.Net's window application.You can implement it in your web page using
java script.

Setting a timeout is done using the window’s setTimeout() method. This method accepts two arguments:
the code to execute and the number of milliseconds (1/1000 of a second) to wait before executing it. The
first argument can either be a string of code (as would be used with the eval() function) or a pointer to a
function. For example, both these lines display an alert after one second:

When you call setTimeout(), it creates a numeric timeout ID, which is similar to a process ID in an
operating system. The timeout ID is essentially an identifier for the delayed process should you decide,
after calling setTimeout(), that the code shouldn’t be executed. To cancel a pending timeout, use the
clearTimeout() method and pass in the timeout ID:

<html >
<head >
    <title>Girfa Timer Demo</title>
    <script language=javascript>
        var i=0;
        var id;
        function sstart()
            var ob=document.getElementById('s1');
        function tstop()
        function tstart()
<body onload="sstart()">
             <span id="s1" style="font-size:x-large">0:0:0</span>
            <input type=button value="start" onclick="tstart()" />
            <input type=button value="stop" onclick="tstop()" />