搜索
byadmin 發表於 2013-5-8 22:57:56 , 2972人已閱讀 , 0人回應
實現網站運行時間 , 其實可以透過簡單JS語法即可實現 , 有了運行時間彷彿網站有了生命的感覺 , 對吧   
應用中心有現成的插件可以使用 , 不過沒辦法指定顯示的地方是個非常大的使用限制 , 因此透過自行添加程式碼到相關模版中, 可實現自定義位置顯示的目的:

修改教學:
1. 打開你想要添加模版 (例如footer.html) , 找到想要擺放的位置 , 加入以下程式碼
  1. 本站<script LANGUAGE="JavaScript"><!--
  2. now = new Date()
  3. nowyear=now.getYear()
  4. if(nowyear<2000)
  5.   nowyear=nowyear+1900
  6. nowmonth=now.getMonth()+1
  7. nowdate=now.getDate()
  8. years=nowyear-2013
  9. months=nowmonth-03
  10. dates=nowdate-01
  11. if((years<0)||((years==0)&&(months<0))||((years==0)&&(months==0)&&(dates<=0)))
  12.   document.write("<span><font color=red>你的系統時間有問題</font></span>")
  13. else {
  14.   if(dates<0) {
  15.    months=months-1
  16.    dates=dates+30
  17.    }
  18.   if(months<0) {
  19.    years=years-1
  20.    months=months+12
  21.    }
  22.   document.write("已運營")
  23.   if (years>0) {
  24.    document.write(years)
  25.    document.write("年")
  26.   }
  27. if(months>0) {
  28.    document.write(months)
  29.    document.write("個月")
  30.   }
  31. if(((years>0)||(months>0))&&(dates>0))
  32.   document.write("零")
  33. if(dates>0) {
  34.   document.write(dates)
  35.   document.write("天")
  36. }
  37. else
  38.   document.write("整")

  39.   
  40.   if((months==0)&&(dates==0)) {
  41.     document.write("<b>今天是SR數位設計工作室的生日!")
  42.   
  43. document.write("</b>")
  44.   }
  45. }
  46. //-->
  47.        </script>
複製代碼
最後圖片的部分是稍微美化過後的樣式 (我是把它添加在搜尋列旁)
網站運行時間.jpg
Traffic Exchange Site
您需要登錄後才可以回帖 登錄 | 立即註冊

作者資訊

文章分類

SR數位設計工作室

  • 服務專線:03-3555-069


ECSHOP購物網站開發|接案說明|線上洽詢|隱私權政策|SR數位設計(CMS)

信箱:sr.design2011@gmail.com

, Processed in 0.178044 second(s), 43 queries , Gzip On.

Copyright © 2011-2014 Template By SR網頁設計清新部落風格

Core - DZ2.5 GMT+8, 2024-3-28 18:13

回頂部