这是错的,你说哪里错了
<html>
<head>
</head>
<body>
<script language="JavaScript">
<!--
todayDate()= new Date();
date= todayDate.getDate();
month= todayDate.getMonth() +1;
year= todayDate.getYear();
document.write("今天是");
document.write("<br>");
if(navigator.appName== "Netscape")
{
document.write(1900+year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日");
document.write("</br>");}
if(navigator.appVersion.indexOf("MSIE")!= -1)
{
document.write(year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日");
document.write("</br>");
}
if(todayDate.getDay()==1)
document.write("星期一");
if(todayDate.getDay()==2)
document.write("星期二");
if(todayDate.getDay()==3)
document.write("星期三");
if(todayDate.getDay()==4)
document.write("星期四");
if(todayDate.getDay()==5)
document.write("星期五");
if(todayDate.getDay()==6)
document.write("星期六");
if(todayDate.getDay()==0)
document.write("星期日");
//-->
</script>
</body>
</html>
这是书上的,你看看哪里不同了
<html>
<head>
</head>
<body>
<script language="JavaScript">
<!--
todayDate()= new Date();
date= todayDate.getDate();
month= todayDate.getMonth() +1;
year= todayDate.getYear();
document.write("今天是");
document.write("<br>");
if(navigator.appName== "Netscape")
{
document.write(1900+year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日");
document.write("</br>");}
if(navigator.appVersion.indexOf("MSIE")!= -1)
{
document.write(year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日");
document.write("</br>");
}
if(todayDate.getDay()==1)
document.write("星期一");
if(todayDate.getDay()==2)
document.write("星期二");
if(todayDate.getDay()==3)
document.write("星期三");
if(todayDate.getDay()==4)
document.write("星期四");
if(todayDate.getDay()==5)
document.write("星期五");
if(todayDate.getDay()==6)
document.write("星期六");
if(todayDate.getDay()==0)
document.write("星期日");
//-->
</script>
</body>
</html>
这是书上的,你看看哪里不同了
<html>
<head>
</head>
<body>
<script language="JavaScript">
<!--
todayDate = new Date();
date = todayDate.getDate();
month= todayDate.getMonth() +1;
year= todayDate.getYear();
document.write("今天是")
document.write("<br>")
if(navigator.appName == "Netscape")
{
document.write(1900+year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日");
document.write("<br>")
}
if(navigator.appVersion.indexOf("MSIE") != -1)
{
document.write(year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日");
document.write("<br>")
}
if (todayDate.getDay() == 5) document.write("星期五")
if (todayDate.getDay() == 6) document.write("星期六")
if (todayDate.getDay() == 0) document.write("星期日")
if (todayDate.getDay() == 1) document.write("星期一")
if (todayDate.getDay() == 2) document.write("星期二")
if (todayDate.getDay() == 3) document.write("星期三")
if (todayDate.getDay() == 4) document.write("星期四")//-->
</script>
</body>
</html>
if (todayDate.getDay() == 5)
document.write("星期五");
if (todayDate.getDay() == 6)
document.write("星期六");
if (todayDate.getDay() == 0)
document.write("星期日");
if (todayDate.getDay() == 1)
document.write("星期一");
if (todayDate.getDay() == 2)
document.write("星期二");
if (todayDate.getDay() == 3)
document.write("星期三");
if (todayDate.getDay() == 4)
document.write("星期四");
书上的:todayDate = new Date();
第一:todayDate()= new Date();
你多加了():todayDate()
第二:if(navigator.appVersion.indexOf("MSIE")!= -1)
这里的括号不对,应该是:
if(navigator.appVersion.indexOf("MSIE")!= -1)你自己改下你的。就这2个。我已经运行过了。如果对了。你就速度结贴给分。
就像在SQL语句里面的一个空格和逗号是一样的,都是不正确不能运行的
<head>
</head>
<body>
<script language="JavaScript">
<!--
todayDate= new Date();date= todayDate.getDate();
month= todayDate.getMonth() +1;
year= todayDate.getYear();
document.write("今天是");
document.write("<br>");
if(navigator.appName== "Netscape")
{
document.write(1900+year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日");
document.write("</br>");}
if(navigator.appVersion.indexOf("MSIE")!= -1)
{
document.write(year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日");
document.write("</br>");
}
if(todayDate.getDay()==1)
document.write("星期一");
if(todayDate.getDay()==2)
document.write("星期二");
if(todayDate.getDay()==3)
document.write("星期三");
if(todayDate.getDay()==4)
document.write("星期四");
if(todayDate.getDay()==5)
document.write("星期五");
if(todayDate.getDay()==6)
document.write("星期六");
if(todayDate.getDay()==0)
document.write("星期日");
//-->
</script>
</body>
</html>
看红色部分就知道了