JS版本

程序代碼 程序代碼
<link rel="stylesheet" type="text/css" href="a.css" id="sitecss" />
<script language="JavaScript">
  function trunCss() {
    var today = new Date();
    var time = today.getHours();
    var cssurl = "";
    if (( time>=0) && (time < 7 ))
      cssurl="1.css"
    if (( time >= 7 ) && (time < 12))
      cssurl="2.css"
    if (( time >= 12) && (time < 14))
      cssurl="3.css"
    if (( time >=14) && (time < 18))
      cssurl="4.css"
    if ((time >= 18) && (time <= 22))
      cssurl="5.css"
    if ((time >= 22) && (time < 24))
      cssurl="6.css"
    document.getElementById("sitecss").href=ccsurl
  }
trunCss();
</script>


PHP版本

程序代碼 程序代碼
<link rel="stylesheet" type="text/css"
href="<?php $hour = date("H"); if ($hour < 12) echo "morning.css"; elseif ($hour < 17) echo "day.css"; else echo "night.css"; ?>
" />


ASP版本

程序代碼 程序代碼
<link rel="stylesheet" type="text/css" href="<%
if hour(now)<12 then
  response.write "a.css"
else
  if hour(now)<17 then
    response.write "b.css"
  else
    response.write "c.css"
  end if
end if
%> " />

 

轉載至:http://www.wowbox.com.tw/blog/article.asp?id=2371

創作者介紹

蛻變之後的藍天

winter1106 發表在 痞客邦 PIXNET 留言(0) 人氣()