首頁 > web前端 > js教程 > js實作倒數時鐘的範例程式碼_javascript技巧

js實作倒數時鐘的範例程式碼_javascript技巧

WBOY
發布: 2016-05-16 17:08:52
原創
1279 人瀏覽過

如下:

複製程式碼 程式碼如下:

if (document.all||document.getElementById)

document.write('')

window.onload=start_countdown

function countdown(){
var today=new Date()
var todayy=today.getYear()
if (todayy 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
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(ddayif (document.layers){
document. countdownnssub.document.write(opentags message_on_occasion closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}return
}
else if (ddayif (document.layers){
(opentags "時間已經過了!" closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementBy}
else if (document.all||document.getElementBy)
crosscount .innerHTML=opentags "Occasion already passed! " closetags
return
}
else{
if (document.layers){
document.countns.document. dday " days, " dhour " hours, " dmin " minutes, and " dsec " seconds left until " occasion closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}crosscount.innerHTML=opentags "還有" dday " 天, " dhour " 小時, " dmin " 分, " dsec " 秒就是" occasion closetags
}
setTimeout("countdown()",1000)
}




height="&{countdownheight};" width="&{countdownwidth};">id=countdownnssub height="&{countdownheight};"
width="&{countdownwidth};" top="0" left="0">



相關標籤:
js
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板