http://cse-mjmcl.cse.bris.ac.uk/blog/2005/08/18/1124396539593.html
smth like this?

On 4 июн, 19:26, jez <j...@h4x3d.com> wrote:
> Hello,
> I am almost certain one of you guys will have a super quick solution
> to this, but I just can't get it and it is doing my head in:
>
> I have this piece of code which basically checks on client-side what
> time of the day it is.
> This information should be used to "use" different stylesheets based
> on the time, e.g.
>
> >=18 will be night.css
> >=15 will be afternoon.css, etc.
>
> however I cannot get to write this piece of html (e.g. <link
> rel="stylesheet" href="night.css" type="text/css" media="screen"
> title="night" charset="utf-8" />) by means of jquery.
>
> I was able to set the class of <body> to either night, afternoon,
> noon, etc, but I would rather like a solution where the time is
> translated into night.css, afternoon.css, etc.
>
> --- see code below ---
>
> //date
>   datetoday = new Date();
>   timenow = datetoday.getTime();
>   datetoday.setTime(timenow);
>   thehour = datetoday.getHours();
>
>   if (thehour >= 18)
>     $('body').addClass('evening');
>   else if (thehour >= 15)
>     $('body').addClass('afternoon');
>   else if (thehour >= 12)
>     $('body').addClass('noon');
>   else if (thehour >= 7)
>     $('body').addClass('morning');
>   else if (thehour >= 0)
>     $('body').addClass('night');
>   else
>     $('body').addClass('general');
> //end
>
> Many thanks in advance for any suggestions and replies!
> Any pointers or brain teasers welcome!

Reply via email to