帮忙看下代码有什么问题

sumjor 2009-10-20 02:58:29

<html>
<head>
<script type="text/javascript">
var theTime = "";
function startTime()
{
theTime = window.setInterval("stTime()",1000);
}

function stopTime()
{
window.clearInterval(theTime);
}

function stTime()
{
today = new Date();
with(today);
{
document.form1.timer.value = getHours()+" 点 "+getMinutes()+" 分 "+getSeconds()+" 秒 ";
}
}

</script>
</head>
<body onLoad="startTime();">
<form name="form1">
<h2>现在时间:</h2>
<input name="timer">
<h2>点击开始计时:</h2>
<input type="button" value="点击开始计时" onClick="startTime()">
<h2>点击停止计时:</h2>
<input type="button" value="点击停止计时" onClick="stopTime()">
</form>
</body>
</html>

...全文
102 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2009-10-20
  • 打赏
  • 举报
回复
这样写,貌似不会有什么效果,按照1楼和3楼的改下就不会有错,但不会有什么效果
sumjor 2009-10-20
  • 打赏
  • 举报
回复
找到原因了
with(today);
我加了个分号 迷糊。。。结账
sumjor 2009-10-20
  • 打赏
  • 举报
回复
将分号改了还是错误,用3楼的办法正常,,,
friendly_ 2009-10-20
  • 打赏
  • 举报
回复
document.form1.timer.value = getHours()+" 点 "+getMinutes()+" 分 "+getSeconds()+" 秒 ";
------------------------>
document.form1.timer.value = getHours()+" 点 "+getMinutes()+" 分 "+getSeconds()+" 秒 ";
vfan2010 2009-10-20
  • 打赏
  • 举报
回复
document.form1.timer.value = today.getHours()+" 点 "+today.getMinutes()+" 分 "+today.getSeconds()+" 秒 ";
sumjor 2009-10-20
  • 打赏
  • 举报
回复
额 刚打错了。。。貌似提示说缺少对象
王集鹄 2009-10-20
  • 打赏
  • 举报
回复
document.form1.timer.value = getHours()+" 点 "+getMinutes()+" 分 "+getSeconds()+" 秒 "


难道是传说中的全角分号?

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧