想在jsp页面中显示系统时间,请问以下代码存在什么问题,就是出不来,急!
<html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/><title>...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>显示时间</title>
<script language="javascript">
function clockon(bgclock){
var now=new Date();
var year=now.getYear();
var month=now.getMonth();
var date=now.getDay();
var week;
month=month+1;
if(month<10) month="0"+month;
if(date<10) date="0"+date;
var arr_week=new Array("星期日","星期一","星期二","星期三","星期
四","星期五","星期六");
week=arr_week[day];
var time="";
time=year+"年"+month+"月"+date+"日"+week;
if(document.all){
bgclock.innerHTML=" "+time;
}
var timer=setTimeout("clockon(bgclock)",0);
}
</script>
</head>
<body onLoad="clockon(bgclock)">
hello,the time is:
<div id="bgclock" class="word_Green"></div>
</body>
</html>
我用其他的代码解决啦,谢谢大家啦 展开
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>显示时间</title>
<script language="javascript">
function clockon(bgclock){
var now=new Date();
var year=now.getYear();
var month=now.getMonth();
var date=now.getDay();
var week;
month=month+1;
if(month<10) month="0"+month;
if(date<10) date="0"+date;
var arr_week=new Array("星期日","星期一","星期二","星期三","星期
四","星期五","星期六");
week=arr_week[day];
var time="";
time=year+"年"+month+"月"+date+"日"+week;
if(document.all){
bgclock.innerHTML=" "+time;
}
var timer=setTimeout("clockon(bgclock)",0);
}
</script>
</head>
<body onLoad="clockon(bgclock)">
hello,the time is:
<div id="bgclock" class="word_Green"></div>
</body>
</html>
我用其他的代码解决啦,谢谢大家啦 展开
3个回答
展开全部
错误的地方是在onLoad=clockon这里 bgclock不是这么传的
把方法里的参数干掉
function clockon(){
var bgclock=document.getElementById("bgclock");
var now=new Date();
var year=now.getYear();
var month=now.getMonth();
var date=now.getDay();
var week;
month=month+1;
if(month<10) month="0"+month;
if(date<10) date="0"+date;
var arr_week=new Array("星期日","星期一","星期二","星期三","星期
四","星期五","星期六");
week=arr_week[day];
var time="";
time=year+"年"+month+"月"+date+"日"+week;
if(document.all){
bgclock.innerHTML=" "+time;
}
var timer=setTimeout("clockon(bgclock)",0);
}
</script>
把方法里的参数干掉
function clockon(){
var bgclock=document.getElementById("bgclock");
var now=new Date();
var year=now.getYear();
var month=now.getMonth();
var date=now.getDay();
var week;
month=month+1;
if(month<10) month="0"+month;
if(date<10) date="0"+date;
var arr_week=new Array("星期日","星期一","星期二","星期三","星期
四","星期五","星期六");
week=arr_week[day];
var time="";
time=year+"年"+month+"月"+date+"日"+week;
if(document.all){
bgclock.innerHTML=" "+time;
}
var timer=setTimeout("clockon(bgclock)",0);
}
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
if(document.all){
bgclock.innerHTML=" "+time;
}
修改为:
if(document.all){
document.all.bgclock.innerHTML=" "+time;
}
试试
bgclock.innerHTML=" "+time;
}
修改为:
if(document.all){
document.all.bgclock.innerHTML=" "+time;
}
试试
追问
试过啦,不行啊
追答
你用的浏览器是IE吗?还是别的?建议使用标准的:
使用document.getElementById("bgclock").innerHTML的方式试试
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-08-14
展开全部
个人认为你的id bgclock用的有问题,我没见过函数变量这么用的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询