这个clearInterval(tmp)为什么不能终止函数的重复调用
想实现的功能如下,
页面上有“显示时间”和“时间静止”两个按钮。
单击“显示时间”,状态栏动态的显示时间。单击“时间静止”,状态栏的时间不再变化。
下面的代码问题是,单击“时间静止“时,状态栏时间不会停,这个该怎么改?
<html>
<script type="text/javascript">
var tmp
function show()
{
var d= new Date();
var k=d.getHours()+ ":" +d.getMinutes()+":" +d.getSeconds()
window.status=k;
tmp=setInterval("show()",1000)
}
function stop()
{
clearInterval(tmp);
}
</script>
<body >
<input type="button" id="t1" value="显示时间" onclick="show()">
<input type="button" id="t2" value="时间静止" onclick="stop()">
</body>
</html>