关于javascript时间动态显示问题 :代码哪有问题,刷新无反应,请高手帮助写一段

functionshow(){varthistime=newDate().toLocaleString();document.getElementById('areabo... function show(){
var thistime = new Date().toLocaleString();
document.getElementById('areabox').innerHTML = thistime;
}
function showTime() {
setInterval(show(), 970); //每秒刷新一次
}

<body onload="showTime();">

<div id="areabox"></div>
</body>
展开
 我来答
raymonlu
2010-10-30 · TA获得超过943个赞
知道小有建树答主
回答量:792
采纳率:0%
帮助的人:765万
展开全部
换成我下面的代码就可以了
<script>
function show(){
var thistime = new Date().toLocaleString();
document.getElementById('areabox').innerHTML = thistime;
}
function showTime() {
setInterval(show, 970); //每秒刷新一次
}
</script>
<body onload="showTime();">

<div id="areabox"></div>
</body>
踏浪帅
2010-10-30 · TA获得超过319个赞
知道小有建树答主
回答量:1900
采纳率:0%
帮助的人:1330万
展开全部
function setcountdown(theyear,themonth,theday){
yr=theyear;mo=themonth;da=theday
}

//////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////

//STEP 1: Configure the countdown-to date, in the format year, month, day:
setcountdown(2005,8,25)

var msg_to='☆距离菲菲[8.25]生日还有:'

//STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
var occasion="1"
var message_on_occasion=""

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area
var countdownwidth='450px'
var countdownheight='10px'
var countdownbgcolor=''
//var opentags='<font face="Verdana"><small>'
var opentags='<font face="Verdana" color="#FF00FF" size="1" align="justify"><small>'
var closetags='</small></font>'

//////////DO NOT EDIT PASS THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility="show"
countdown(2005,8,28)
}

if (document.all)
document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')

window.onload=start_countdown

function countdown(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[mo-1]+" "+da+", "+yr
dd=Date.parse(futurestring)-Date.parse(todaystring)

dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all)
countdownie.innerHTML=opentags+message_on_occasion+closetags
return
}
else{
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all)
countdownie.innerHTML=opentags+msg_to+""+dday+ "天"+dhour+"小时"+dmin+"分钟"+dsec+"秒☆ "
}
setTimeout("countdown()",1000)
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式