It is a good idea to automatically adjust the site style based on time. This automatic adjustment of the site style based on time is nothing new. Article Or method, but I didn't pay special attention to it at the time. The following describes their implementation methods. Currently, there are two implementation methods on the Internet:
I. Use server-sideCode
ASP version:
<LINK rel = "stylesheet" type = "text/CSS" href ="
<%
If hour (now) <12 then
Response. Write "morning.css"
Elseif hour (now) <17 then
Response. Write "day.css"
Else
Response. Write "maid"
End if
%>
"/>
PHP version:
<LINK rel = "stylesheet" type = "text/CSS" href ="
<? PHP
$ Hour = Date ("h ");
If ($ hour <12)
Echo 'morning.css ';
Else if ($ hour <17)
Echo 'day.css ';
Else
Echo 'night.css ';
?>
"/>
Ii. use JavaScript code
<SCRIPT type = "text/JavaScript">
<! -
Function getcss (){
Datetoday = new date ();
Timenow = datetoday. gettime ();
Datetoday. settime (timenow );
Thehour = datetoday. gethours ();
If (thehour <12)
Display = "morning.css ";
Else if (thehour <17)
Display = "day.css ";
Else
Display = "maid ";
//(... I want to add more ...)
VaR CSS = '<';
CSS + = 'link rel = "stylesheet" href = '+ display + '\/';
CSS + = '> ';
Document. Write (CSS );
}
->
</SCRIPT>