这是一个简单的JS计时器,可以用作轮询api之类的。
<html><body><input type="text" id="clock" size="35" /><div id ="div"></div><script language=javascript>var int=self.setInterval("clock()",50)function clock(){var t=new Date()document.getElementById("clock").value=t;document.getElementById('div').innerHTML = '文曦博客报时,当前时间:' + t;}</script></form><button onclick="int = self.setInterval('clock()',50)">开始 interval</button><button onclick="int = window.clearInterval(int)">暂停 interval</button></body></html><html> <body> <input type="text" id="clock" size="35" /> <div id ="div"> </div> <script language=javascript> var int=self.setInterval("clock()",50) function clock() { var t=new Date() document.getElementById("clock").value=t; document.getElementById('div').innerHTML = '文曦博客报时,当前时间:' + t; } </script> </form> <button onclick="int = self.setInterval('clock()',50)"> 开始 interval</button> <button onclick="int = window.clearInterval(int)"> 暂停 interval</button> </body> </html><html> <body> <input type="text" id="clock" size="35" /> <div id ="div"> </div> <script language=javascript> var int=self.setInterval("clock()",50) function clock() { var t=new Date() document.getElementById("clock").value=t; document.getElementById('div').innerHTML = '文曦博客报时,当前时间:' + t; } </script> </form> <button onclick="int = self.setInterval('clock()',50)"> 开始 interval</button> <button onclick="int = window.clearInterval(int)"> 暂停 interval</button> </body> </html>
© 版权声明
THE END
暂无评论内容