我正在为课堂做作业,我直接从书中复制了这段代码,但它不起作用。问题是 copyRight() 函数没有显示。countDown() 函数正在其他地方显示,并且运行良好。有人看到我在这里做错了吗?
function countDown() {
var today = new Date()
var dayofweek = today.toLocaleString()
dayLocate = dayofweek.indexOf(" ")
weekDay = dayofweek.substring(0, dayLocate)
newDay = dayofweek.substring(dayLocate)
dateLocate = newDay.indexOf(",")
monthDate = newDay.substring(0, dateLocate+1)
yearLocate = dayofweek.indexOf("2013")
year = dayofweek.substr(yearLocate, 4)
var bridalExpo = new Date("February 12, 2014")
var daysToGo = bridalExpo.getTime()-today.getTime()
var daysToBridalExpo = Math.ceil(daysToGo/(1000*60*60*24))
displayCountDown.innerHTML = "<p style='font-size:12pt; font-family: helvetica;'>Today is "
+weekDay+" "+monthDate+" "+year+". We Have "+daysToBridalExpo+
" days until the Midwest Bridal Expo.</p>"
}
function copyRight() {
var lastModDate = document.lastModified
var lastModDate = lastModDate.substring(0,10)
displayCopyRight.innerHTML = "<p style='font-size:12pt; font-family:helvetica;'>Today is "
+weekDay+" "+monthDate+" "+year+". We have "+daysToBridalExpo+
" days until the Midwest Bridal Expo.</p>"
}
body 标签看起来像这样:(其他两个功能很好用)
<body onload="scrollColor(); countDown(); copyRight()">
copyRight() 函数的调用如下所示:
<div id="displayCopyRight"></div>
过去半小时我一直在看这个,但没有看到它。这也是我第一次编写javascript,所以我可能遗漏了一些东西。任何帮助是极大的赞赏!
谢谢,汤米