代码如下:
<html>
<head>
<script language="javascript">
var id;
function GetTime()
{
var time = new Date();
form1.text1.value = time.toLocaleString();
}
function ShowTime()
{
id = setInterval("GetTime()",1000);
}
// function Cancel()
// {
// clearInterval(id);
// }
</script>
</head>
<body onLoad="ShowTime()">
<form name="form1" method="post" action="">
当前时间为:<input type="text" name="text1" style="width:300px;height:20px" />
<input type="button" name="cancel" value="暂停" onclick="window.clearInterval(id);" />
</form>
</body>
</html>这里onclick用<head>标签里的变量id作为参数传入好像没达到预期效果。用注释掉的cancle函数响应可以。这是为什么?
是变量生命周期的问题么?求教
<html>
<head>
<script language="javascript">
var id;
function GetTime()
{
var time = new Date();
form1.text1.value = time.toLocaleString();
}
function ShowTime()
{
id = setInterval("GetTime()",1000);
}
// function Cancel()
// {
// clearInterval(id);
// }
</script>
</head>
<body onLoad="ShowTime()">
<form name="form1" method="post" action="">
当前时间为:<input type="text" name="text1" style="width:300px;height:20px" />
<input type="button" name="cancel" value="暂停" onclick="window.clearInterval(id);" />
</form>
</body>
</html>这里onclick用<head>标签里的变量id作为参数传入好像没达到预期效果。用注释掉的cancle函数响应可以。这是为什么?
是变量生命周期的问题么?求教
解决方案 »
- html页面有一排的工具栏,分a,b两类,还有两个控制区域c和d。通过变换c、d区域点击,切换a,b工具栏可用
- js对象属性的动态添加
- window.open打不开页面
- 有没有办法在网页运行后,通过点击单元格(含颜色)来实现网页的渐进色
- 表格行的现实与隐藏
- 高手帮个忙吧~~~~
- 急::::如何在WEB页上实现TAB分页的效果,即每个TAB标签显示时对应的内容不同?
- 在框架页如何用js给其中的一个frame赋src值
- 关于 window.open的问题!!在线等待,谢谢各位的帮忙!
- 关于JS运动的一个小问题
- Js 动态添加table时 样式无法显示 求解~~~~~
- 求助属性 :FF下 jquery取不到html()
<head>
<script language="javascript">
var id;
function GetTime() {
var time = new Date();
form1.text1.value = time.toLocaleString();
}
function ShowTime() {
id = setInterval("GetTime()", 1000);
}
function Cancel()
{
clearInterval(id);
}
</script>
</head>
<body onLoad="ShowTime()">
<form name="form1" method="post" action="">
当前时间为:<input type="text" name="text1" style="width:300px;height:20px" />
<input type="button" name="cancel" value="暂停" onclick="Cancel()" />
</form>
</body>
</html>
你那是什么传参啊