一个简单定义问题!请大家帮忙看看要怎么定义

luckyboy97 2004-10-10 09:20:22
clock.innerHTML=timestring;
提示clock未定义,应该怎么定义呢?
...全文
108 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
luckyboy97 2004-10-10
  • 打赏
  • 举报
回复
上面是我的全部JSP文件,按照你说的将clock.innerHTML=timestring; 改为document.clock.innerHTML=timestring;也是不行的
luckyboy97 2004-10-10
  • 打赏
  • 举报
回复
<%@ page import ="java.util.*"%>
<%@ page import ="java.sql.*"%>
<%@ page contentType="text/html;charset=GB2312" %>
<html><head><title>获取系统时间</title>
<script><!--
function tick(clock){
var hours,minutes,seconds,ap;
var inthours,intminutes,intseconds;
var today,timestring;
today=new Date();
inthours=today.getHours();
intminutes=today.getMinutes();
intseconds=today.getSeconds();
if(inthours==0){
hours="12:";
ap="midnight";
}else if(inthours<12){
hours=inthours+":";
ap="A.M.";
}else if(inthours==12){
hours=inthours+":";
ap="noon";
}else if(inthours=inthours-12){
hours=inthours+":";
ap="P.M.";
}
if(intminutes<10){
minutes="0"+intminutes+":";
}else{
minutes=intminutes+":";
}
if(intseconds<10){
seconds="0"+intseconds+" ";
}else{
seconds=intseconds+" ";
}
timestring=hours+minutes+seconds+ap;
//var clock = document.all.clock;
clock.innerHTML=timestring;
window.settimeout("tick(clock.id)",100);
}
window.onload=tick();
//-->
</script>
</head>
<body>
<h1>系统时间</h1>
<div id="clock" align="center" style="font-size:36;color:#0000ff"
onmouseover="this.style.cursor='hand'"
onclick="alert('现在的时间是:'+'n'+timestring)">
<script><!--
tick(clock);
//-->
</script>

<p>请单击获取系统时间</p>
</div>
</body>
</html>
lordofthering 2004-10-10
  • 打赏
  • 举报
回复
document.clock.innerHTML=timestring;

81,122

社区成员

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

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