首頁 考試吧論壇 Exam8視線 考試商城 網(wǎng)絡(luò)課程 模擬考試 考友錄 實(shí)用文檔 求職招聘 論文下載
2011中考 | 2011高考 | 2012考研 | 考研培訓(xùn) | 在職研 | 自學(xué)考試 | 成人高考 | 法律碩士 | MBA考試
MPA考試 | 中科院
四六級(jí) | 職稱英語 | 商務(wù)英語 | 公共英語 | 托福 | 雅思 | 專四專八 | 口譯筆譯 | 博思 | GRE GMAT
新概念英語 | 成人英語三級(jí) | 申碩英語 | 攻碩英語 | 職稱日語 | 日語學(xué)習(xí) | 法語 | 德語 | 韓語
計(jì)算機(jī)等級(jí)考試 | 軟件水平考試 | 職稱計(jì)算機(jī) | 微軟認(rèn)證 | 思科認(rèn)證 | Oracle認(rèn)證 | Linux認(rèn)證
華為認(rèn)證 | Java認(rèn)證
公務(wù)員 | 報(bào)關(guān)員 | 銀行從業(yè)資格 | 證券從業(yè)資格 | 期貨從業(yè)資格 | 司法考試 | 法律顧問 | 導(dǎo)游資格
報(bào)檢員 | 教師資格 | 社會(huì)工作者 | 外銷員 | 國際商務(wù)師 | 跟單員 | 單證員 | 物流師 | 價(jià)格鑒證師
人力資源 | 管理咨詢師考試 | 秘書資格 | 心理咨詢師考試 | 出版專業(yè)資格 | 廣告師職業(yè)水平
駕駛員 | 網(wǎng)絡(luò)編輯
衛(wèi)生資格 | 執(zhí)業(yè)醫(yī)師 | 執(zhí)業(yè)藥師 | 執(zhí)業(yè)護(hù)士
會(huì)計(jì)從業(yè)資格考試會(huì)計(jì)證) | 經(jīng)濟(jì)師 | 會(huì)計(jì)職稱 | 注冊(cè)會(huì)計(jì)師 | 審計(jì)師 | 注冊(cè)稅務(wù)師
注冊(cè)資產(chǎn)評(píng)估師 | 高級(jí)會(huì)計(jì)師 | ACCA | 統(tǒng)計(jì)師 | 精算師 | 理財(cái)規(guī)劃師 | 國際內(nèi)審師
一級(jí)建造師 | 二級(jí)建造師 | 造價(jià)工程師 | 造價(jià)員 | 咨詢工程師 | 監(jiān)理工程師 | 安全工程師
質(zhì)量工程師 | 物業(yè)管理師 | 招標(biāo)師 | 結(jié)構(gòu)工程師 | 建筑師 | 房地產(chǎn)估價(jià)師 | 土地估價(jià)師 | 巖土師
設(shè)備監(jiān)理師 | 房地產(chǎn)經(jīng)紀(jì)人 | 投資項(xiàng)目管理師 | 土地登記代理人 | 環(huán)境影響評(píng)價(jià)師 | 環(huán)保工程師
城市規(guī)劃師 | 公路監(jiān)理師 | 公路造價(jià)師 | 安全評(píng)價(jià)師 | 電氣工程師 | 注冊(cè)測繪師 | 注冊(cè)計(jì)量師
繽紛校園 | 實(shí)用文檔 | 英語學(xué)習(xí) | 作文大全 | 求職招聘 | 論文下載 | 訪談 | 游戲
您現(xiàn)在的位置: 考試吧(Exam8.com) > 軟件水平考試 > 復(fù)習(xí)資料 > 網(wǎng)頁制作 > 正文

網(wǎng)頁特效:輸入生日即可計(jì)算出下個(gè)生日的天數(shù)及存活天數(shù)

  要完成此效果需要三個(gè)步驟

  第一步:把如下代碼加入到<head>區(qū)域中

  <script LANGUAGE="Javascript">
  <!-- Begin
  var byear = prompt(‘請(qǐng)輸入你的出生年份‘,‘1976‘);
  var mm = prompt(‘請(qǐng)輸入你的出生月份‘,‘11‘);
  var bday = prompt(‘請(qǐng)輸入你的出生日‘,‘2‘);
  var year = new Date();
  var year2 = year.getYear();
  var year3 = (year < 2000) ? year2 + 1900 : year2;
  thedate = new Date();
  mm2 = thedate.getMonth() + 1;
  dd2 = thedate.getDate();
  yy2 = thedate.getYear();
  if (yy2 < 100) yy2 += 1900
  yourage = yy2 - byear;
  if (mm2 < mm) yourage--;
  if ((mm2 == mm) && (dd2 < bday)) yourage--;
  TMonth = new Array(
  ‘January‘,‘February‘,‘March‘,
  ‘April‘,‘May‘,‘June‘,‘July‘,
  ‘August‘,‘September‘,‘October‘,
  ‘November‘,‘December‘
  );
  CurMonth = mm - 1;
  bmonth = TMonth[CurMonth];
  var age2 = yourage + 1;
  var timerID;
  var timerRunning = false;
  var today = new Date();
  var startday = new Date();
  var enday = new Date();
  var secPerDay = 0;
  var minPerDay = 0;
  var hourPerDay = 0;
  var secsLeft = 0;
  var secsRound = 0;
  var secsRemain = 0;
  var minLeft = 0;
  var minRound = 0;
  var minRemain = 0;
  var timeRemain = 0;
  function stopclock() {
   if(timerRunning)
   clearTimeout(timerID);
   timerRunning = false;
  }
  function startclock() {
   stopclock();
   showtime();
   showtime1();
  }
  function showtime() {
   today = new Date();
   enday = new Date(""+bmonth+", "+bday+" "+year3+" 00:00");
   enday.setYear(""+year3+"");
   secsPerDay = 1000 ;
   minPerDay = 60 * 1000 ;
   hoursPerDay = 60 * 60 * 1000;
   PerDay = 24 * 60 * 60 * 1000;
   secsLeft = (enday.getTime() - today.getTime()) / minPerDay;
   secsRound = Math.round(secsLeft);
   secsRemain = secsLeft - secsRound;
   secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain =
   (secsLeft - secsRound) * 60;
   secsRemain = Math.round(secsRemain);
   minLeft = ((enday.getTime() - today.getTime()) / hoursPerDay);
   minRound = Math.round(minLeft);
   minRemain = minLeft - minRound;|||    minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft)  * 60) : minRemain =
   ((minLeft - minRound) * 60);
   minRemain = Math.round(minRemain - 0.495);
   hoursLeft = ((enday.getTime() - today.getTime()) / PerDay);
   hoursRound = Math.round(hoursLeft);
   hoursRemain = hoursLeft - hoursRound;
   hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft)  * 24) :
   hoursRemain = ((hoursLeft - hoursRound) * 24);
   hoursRemain = Math.round(hoursRemain - 0.5);
   daysLeft = ((enday.getTime() - today.getTime()) / PerDay);
   daysLeft = (daysLeft - 0.5);
   daysRound = Math.round(daysLeft);
   daysRemain = daysRound;
   if (daysRemain == 1) day_rem = " 天, "
   else day_rem = " 天, "
   if (hoursRemain == 1) hour_rem = " 小時(shí), "
   else hour_rem = " 小時(shí), "
   if (minRemain == 1) min_rem = " 分鐘, "
   else min_rem = " 分鐘, "
   if (secsRemain == 1) sec_rem = " 秒"
   else sec_rem = " 秒"
   timeRemain = daysRemain + day_rem + hoursRemain + hour_rem + minRemain + min_rem + secsRemain +
   sec_rem;
   document.down.face.value = timeRemain;
   timerID = setTimeout("showtime()",1000);
   timerRunning = true;
   if (daysRemain < 0) year3 = year3 + 1
  }
  function showtime1() {
   startday = new Date(""+bmonth+" "+bday+", "+byear+" 00:00 EDT");
   startday.setYear(""+byear+"");
   today = new Date();
   secsPerDay = 1000 ;
   minPerDay = 60 * 1000 ;
   hoursPerDay = 60 * 60 * 1000;
   PerDay = 24 * 60 * 60 * 1000;
   secsLeft = (today.getTime() - startday.getTime()) / minPerDay;
   secsRound = Math.round(secsLeft);
   secsRemain = secsLeft - secsRound;
   secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain =
   (secsLeft - secsRound) * 60;
   secsRemain = Math.round(secsRemain);
   minLeft = ((today.getTime() - startday.getTime()) / hoursPerDay);
   minRound = Math.round(minLeft);
   minRemain = minLeft - minRound;
   minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60) : minRemain =
   ((minLeft - minRound) * 60);
   minRemain = Math.round(minRemain - 0.495);
   hoursLeft = ((today.getTime() - startday.getTime()) / PerDay);
   hoursRound = Math.round(hoursLeft);
   hoursRemain = hoursLeft - hoursRound;
   hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft) * 24)  :
   hoursRemain = ((hoursLeft - hoursRound) * 24);
   hoursRemain = Math.round(hoursRemain - 0.5);
   daysLeft = ((today.getTime() - startday.getTime()) / PerDay);
   daysLeft = (daysLeft - 0.5);
   daysRound = Math.round(daysLeft);
   daysRemain = daysRound;
   if (daysRemain == 1) day_rem = " 天, "
   else day_rem = " 天, "
   if (hoursRemain == 1) hour_rem = " 小時(shí), "
   else hour_rem = " 小時(shí), "
   if (minRemain == 1) min_rem = " 分鐘, "
   else min_rem = " 分鐘, "
   if (secsRemain == 1) sec_rem = " 秒"
   else sec_rem = " 秒"
   timeRemain = daysRemain + day_rem + hoursRemain + hour_rem + minRemain + min_rem + secsRemain +
   sec_rem;
   document.up.face.value = timeRemain;
   timerID = setTimeout("showtime1()",1000);
   timerRunning = true;
  }
  //  End -->
  </script>

|||

  第二步:把如下代碼加入到<body>區(qū)域中

  <center>
  <form name="down" onSubmit="0">
  <script Language="Javascript">
  document.write("<b>你的出生日是:"+byear+"  年 "+mm+" 月 "+bday+" 日 .
  ("+mm+"/"+bday+"/"+byear+")</b>");
  document.write("<br><br>今年你已經(jīng) "+yourage+" 歲了, 你離 "+age2+" 歲還有:");
  </script>
  <br>
  <input type="text" name="face" size="47" value="A browser supporting Javascript 1.1+ is needed.">
  </form>
  <p>
  <br>
  <form name="up" onSubmit="1">
  以下是你在這世上存活的時(shí)間<br>
  <input type="text" name="face" size="47" value="A browser supporting Javascript 1.1+ is needed.">
  </form>
  </center>

  第三步:把“OnLoad="startclock()"”加在<body>標(biāo)記里

  例如:<body OnLoad="startclock()">

1 2  下一頁
文章搜索
軟件水平考試欄目導(dǎo)航
版權(quán)聲明:如果軟件水平考試網(wǎng)所轉(zhuǎn)載內(nèi)容不慎侵犯了您的權(quán)益,請(qǐng)與我們聯(lián)系800@exam8.com,我們將會(huì)及時(shí)處理。如轉(zhuǎn)載本軟件水平考試網(wǎng)內(nèi)容,請(qǐng)注明出處。