document.getElementById('year').innerHTML=str;运行错误
<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 type="text/javascript" >
function rili()
{
var nowdata = new Date();
var nowyear = nowdata.getYear();
var nowmonth = nowdata.getMonth()+1;
nowmonth = checkmd(nowmonth);
if(nowyear<2000)
{nowyear = nowyear + 1900;}
document.write( nowyear + "年" + nowmonth + "月")
var str= nowyear + "年" + nowmonth + "月"
document.write( str);
document.getElementById('year').innerHTML=str;
}
function checkmd(i)
{
if (i<10)
{i="0" + i;}
return i;
}
</script>
</head>
<body onload="rili()" >
<TABLE border>
<TR>
<TD colspan = 7 id = "year" ></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
</body>
</html>
显示“ocument.getElementById('year').innerHTML=str”is null or not an object 展开
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" >
function rili()
{
var nowdata = new Date();
var nowyear = nowdata.getYear();
var nowmonth = nowdata.getMonth()+1;
nowmonth = checkmd(nowmonth);
if(nowyear<2000)
{nowyear = nowyear + 1900;}
document.write( nowyear + "年" + nowmonth + "月")
var str= nowyear + "年" + nowmonth + "月"
document.write( str);
document.getElementById('year').innerHTML=str;
}
function checkmd(i)
{
if (i<10)
{i="0" + i;}
return i;
}
</script>
</head>
<body onload="rili()" >
<TABLE border>
<TR>
<TD colspan = 7 id = "year" ></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
</body>
</html>
显示“ocument.getElementById('year').innerHTML=str”is null or not an object 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询