村長fb!
魚蛋村 yudans語法區語法範例 → 倒數日子時鐘

倒數日子時鐘

  • Internet Explorer 6.0
  • Internet Explorer 7.0
  • Internet Explorer 8.0
  • Mozilla Firefox 2.0
  • Mozilla Firefox 3.0
  • Google Chrome
  • Safari 3.1
  • Opera 9.5
  • 語法介紹 Introduction:
  • 倒數日子時鐘 - 計算與指定日期的日數和秒數。
  • 語法總長度:1309 字元
  • 範例 Example:
  • 請將以下程式碼貼到<body>與</body>之間:
<div id="yudan114"></div>
<script type="text/javascript"><!--
var before="";
var current="終於到了!!! yeah!!!!!!!";
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function countdown(yr,m,d){
theyear=yr; themonth=m; theday=d;
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[m-1]+" "+d+", "+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) {
document.getElementById("yudan114").innerHTML = current; return;}
else{document.getElementById("yudan114").innerHTML = 
"還有 "+dday+" 日 "+dhour+" 小時 "+dmin+" 分 "+dsec+" 秒便到 2012年啦";}
setTimeout("countdown(theyear,themonth,theday)",1000);}
countdown(2012,1,1);
// --></script>
  • 可修改的地方 Modify:
  • 可修改第 4 和 26 行的文字
  • 在第 28 行設定要倒數的日子
    countdown(2012,1,1);
魚蛋村,語法,圖片,素材,下載,琴譜,字型,教學,網頁製作,網頁教學,表情符號,程式,yudan,yudans,yudan village,javascript,cgi,php,msn,css,html,w3c,teach
footer