javascript新手问题:下面程序有个错问
<html><head><metaname="generator"content="microsoftvisualstudio6.0"><title>动态数字时钟</ti...
<html>
<head>
<meta name="generator" content="microsoft visual studio 6.0">
<title> 动态数字时钟 </title>
<script language=javascript>
var clockbgcolor="infobackground";
var clockfgcolor="infotext";
var clockborder=1;
function clocktick(){
thistime=new date();
year=thistime.getyear();
month=thistime.getmonth()+1;
day=thistime.getdate();
hours=thistime.gethours();
minutes=thistime.getminutes();
seconds=thistime.getseconds();
if(hours<10){hours="0"+hours}
if(minutes<10){minutes="0"+minutes}
if(seconds<10){seconds="0"+seconds}
thistime=year+"年"+month+"月"+day+"日";
thistime=thistime+"<br>"+hours+":"+minutes+":"+seconds;
if(clockborder!==0)
thistime='<table border='clockborder' width="100%" height="100%"><tr><td style=''text-align:center;color;'+clockfgcolor+'''>+thistime+</td></tr></table>';这里有个missing;before statement。。。不知道怎么回事?
clockdiv.innerhtml=thistime;
}
document.writeln("<div id=clockdiv style="text-align:center;width:120;height:50;color;"+"background-color:"+clockbgcolor+""></div>");
setinterval("clocktick()",1000);
</script>
</head>
<body>
</body>
</html> 展开
<head>
<meta name="generator" content="microsoft visual studio 6.0">
<title> 动态数字时钟 </title>
<script language=javascript>
var clockbgcolor="infobackground";
var clockfgcolor="infotext";
var clockborder=1;
function clocktick(){
thistime=new date();
year=thistime.getyear();
month=thistime.getmonth()+1;
day=thistime.getdate();
hours=thistime.gethours();
minutes=thistime.getminutes();
seconds=thistime.getseconds();
if(hours<10){hours="0"+hours}
if(minutes<10){minutes="0"+minutes}
if(seconds<10){seconds="0"+seconds}
thistime=year+"年"+month+"月"+day+"日";
thistime=thistime+"<br>"+hours+":"+minutes+":"+seconds;
if(clockborder!==0)
thistime='<table border='clockborder' width="100%" height="100%"><tr><td style=''text-align:center;color;'+clockfgcolor+'''>+thistime+</td></tr></table>';这里有个missing;before statement。。。不知道怎么回事?
clockdiv.innerhtml=thistime;
}
document.writeln("<div id=clockdiv style="text-align:center;width:120;height:50;color;"+"background-color:"+clockbgcolor+""></div>");
setinterval("clocktick()",1000);
</script>
</head>
<body>
</body>
</html> 展开
1个回答
展开全部
帮你改过了:
<html>
<head>
<meta name="generator" content="microsoft visual studio 6.0">
<title> 动态数字时钟 </title>
<script language=javascript>
var clockbgcolor="#000000";
var clockfgcolor="#FF0000";
var clockborder=1;
function clocktick(){
thistime=new Date();
year=thistime.getYear();
month=thistime.getMonth()+1;
day=thistime.getDate();
hours=thistime.getHours();
minutes=thistime.getMinutes();
seconds=thistime.getSeconds();
if(hours<10){hours="0"+hours}
if(minutes<10){minutes="0"+minutes}
if(seconds<10){seconds="0"+seconds}
thistime=year+"年"+month+"月"+day+"日";
thistime=thistime+"<br>"+hours+":"+minutes+":"+seconds;
if(clockborder!==0)
thistime='<table border='+clockborder+ ' width="100%" height="100%"><tr><td style="text-align:center;color:'+clockfgcolor+';"'+'>'+thistime+'</td></tr></table>'//这里有个missing;before statement。。。不知道怎么回事?
clockdiv.innerHTML=thistime;
}
document.writeln("<div id=clockdiv style='text-align:center;width:120;height:50;color:"+clockfgcolor+";background-color"+clockbgcolor+";'></div>");
setInterval("clocktick()",1000);
</script>
</head>
<body>
</body>
</html>
//编写jsp代码应试注意大小写,另外输出字符串时要注意引号与括号等的配对。
<html>
<head>
<meta name="generator" content="microsoft visual studio 6.0">
<title> 动态数字时钟 </title>
<script language=javascript>
var clockbgcolor="#000000";
var clockfgcolor="#FF0000";
var clockborder=1;
function clocktick(){
thistime=new Date();
year=thistime.getYear();
month=thistime.getMonth()+1;
day=thistime.getDate();
hours=thistime.getHours();
minutes=thistime.getMinutes();
seconds=thistime.getSeconds();
if(hours<10){hours="0"+hours}
if(minutes<10){minutes="0"+minutes}
if(seconds<10){seconds="0"+seconds}
thistime=year+"年"+month+"月"+day+"日";
thistime=thistime+"<br>"+hours+":"+minutes+":"+seconds;
if(clockborder!==0)
thistime='<table border='+clockborder+ ' width="100%" height="100%"><tr><td style="text-align:center;color:'+clockfgcolor+';"'+'>'+thistime+'</td></tr></table>'//这里有个missing;before statement。。。不知道怎么回事?
clockdiv.innerHTML=thistime;
}
document.writeln("<div id=clockdiv style='text-align:center;width:120;height:50;color:"+clockfgcolor+";background-color"+clockbgcolor+";'></div>");
setInterval("clocktick()",1000);
</script>
</head>
<body>
</body>
</html>
//编写jsp代码应试注意大小写,另外输出字符串时要注意引号与括号等的配对。
追问
年份显示不对啊!显示是111,background-color"+clockbgcolor+",为什么要用加号啊!"+clockbgcolor+“
追答
更正下:+clockfgcolor+";background-color"+clockbgcolor+";'中少了一个“:”应为:
+clockfgcolor+";background-color:"+clockbgcolor+";'
年份在我测试中没有问题(IE8)
“+”是用来连接字符串的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询