js實(shí)現(xiàn)倒計(jì)時(shí)時(shí)鐘的示例代碼
如下所示:
<!--將以下代碼加入HTML的<Body></Body>之間-->
<SCRIPT language=JavaScript1.2>
function setcountdown(theyear,themonth,theday){
yr=theyear;mo=themonth;da=theday
}
setcountdown(2008,7,12)
var occasion="2008北京奧運(yùn)會(huì)"
var message_on_occasion="盼望已久的時(shí)刻終于來到了!"
var countdownwidth='480px'
var countdownheight='20px'
var countdownbgcolor='tan'
var opentags='<font face="宋體"><small>'
var closetags='</small></font>'
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''
function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
countdown()
}
if (document.all||document.getElementById)
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&&todayd==da){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+message_on_occasion+closetags
return
}
else if (dday<=-1){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+"時(shí)間已經(jīng)過了!"+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+"Occasion already passed! "+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||document.getElementById)
crosscount.innerHTML=opentags+"還有 "+dday+ " 天, "+dhour+" 小時(shí), "+dmin+" 分, "+dsec+" 秒 就是 "+occasion+closetags
}
setTimeout("countdown()",1000)
}
</SCRIPT>
<SCRIPT type="text/javascript" src=""></SCRIPT>
<SCRIPT language="JavaScript">
<!--
BaiduWriteAD("zouwenyedg","3");
//-->
</SCRIPT>
<ILAYER id=countdownnsmain visibility="hide" bgColor="&{countdownbgcolor};"
height="&{countdownheight};" width="&{countdownwidth};"><LAYER
id=countdownnssub height="&{countdownheight};"
width="&{countdownwidth};" top="0" left="0"></LAYER></ILAYER>
- js+SVG實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘效果
- html5 canvas js(數(shù)字時(shí)鐘)實(shí)例代碼
- js實(shí)現(xiàn)一個(gè)簡(jiǎn)單的數(shù)字時(shí)鐘效果
- JavaScript實(shí)現(xiàn)簡(jiǎn)單的時(shí)鐘實(shí)例代碼
- 基于javascript實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘效果
- javascript入門·動(dòng)態(tài)的時(shí)鐘,顯示完整的一些方法,新年倒計(jì)時(shí)
- JS實(shí)現(xiàn)的網(wǎng)頁倒計(jì)時(shí)數(shù)字時(shí)鐘效果
- 超級(jí)可愛純js網(wǎng)頁時(shí)鐘
- js實(shí)現(xiàn)簡(jiǎn)單秒表走動(dòng)的時(shí)鐘特效
- 基于D3.js實(shí)現(xiàn)時(shí)鐘效果
相關(guān)文章
Winform客戶端向web地址傳參接收參數(shù)的方法
這篇文章主要介紹了Winform客戶端向web地址傳參接收參數(shù)的方法的相關(guān)資料,需要的朋友可以參考下2016-05-05mui開發(fā)中獲取單選按鈕、復(fù)選框的值(實(shí)例講解)
下面小編就為大家?guī)硪黄猰ui開發(fā)中獲取單選按鈕、復(fù)選框的值(實(shí)例講解)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-07-07js實(shí)現(xiàn)視圖和數(shù)據(jù)雙向綁定的方法分析
這篇文章主要介紹了js實(shí)現(xiàn)視圖和數(shù)據(jù)雙向綁定的方法,結(jié)合實(shí)例形式分析了vue.js及jQuery數(shù)據(jù)綁定相關(guān)操作技巧與注意事項(xiàng),需要的朋友可以參考下2020-02-02用javascrpt將指定網(wǎng)頁保存為Excel的代碼
這段代碼在服務(wù)器中沒有權(quán)限,可以保存在本地,存為htm文件,運(yùn)行即可,就可以把文本內(nèi)容存為excel文件了2008-01-01JavaScript的變量聲明提升問題淺析(Hoisting)
大家應(yīng)該都只奧javascript的變量聲明具有hoisting機(jī)制,JavaScript引擎在執(zhí)行的時(shí)候,會(huì)把所有變量的聲明都提升到當(dāng)前作用域的最前面。網(wǎng)上關(guān)于JavaScript的變量聲明提升問題的文章有很多,這篇文章將再次談?wù)勱P(guān)于這方面的問題,有需要的朋友們可以參考借鑒。2016-11-11