<input type="button" value="start" onclick="h=setInterval('showTime()',1000);"/>

解决方案 »

  1.   

    <html>
    <script>
    var h=null;
    function showTime()
    {
        var today = new Date();    document.getElementById("test").innerHTML = "The time is: " + today.toString();}
    </script>
    <body>
    <span id="test" ></span><a style="display:none" href="http://silverlight.net/showcase/">silverlight</a>
    <input type="button" value="stop" onclick="if(h===null)return;clearInterval(h);h=null"/>
    <input type="button" value="start" onclick="if(h!=null)return;h=setInterval('showTime()',1000);"/>
    </body>
    </html>