Code Snippet
Different Stylesheets for Different Days of the Week
<script type="text/javascript">
<!--
dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
dayNumber = new Date().getDay();
document.writeln('<link rel="stylesheet" type="text/css" href="' + dayNames[dayNumber] + '.css">');
//-->
</script>
<noscript>
<link rel="stylesheet" type="text/css" href="default.css">
</noscript>
Name your css files accordingly: Saturday.css, Friday.css, Sunday.css, etc...
If JavaScript is disabled in the browser, it will revert back to the default.css file.
Don’t use document.write, it will cause the page from displaying a white page for a few seconds before it processes the rest of page. I suggest using a document.createElement instead.
Because white page of deaths is something your really want to prevent when you are working with dynamic stylesheet generation.
For example:
var dSS = {
names: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
number: new Date().getDay(),
link: document.createElement('link')
}
dSS.link.rel = "stylesheet";
dSS.link.type = "text/css";
dSS.link.href = dSS.names[ dSS.number ] + ".css";
document.getElementsByTagName('head')[0].appendChild( dSS.link );
how would you create a time verision.
so at a certain time it changes??
So where do you write the css files?
above given code is greet.
can u please create java script code on time basis.
means,
12:00am – 4:00 am —– night.css etc,
please….
DigWP
A book and blog co-authored by Jeff Starr and myself about the World's most popular publishing platform.
Quotes on Design
Design, like Art, can be an elusive word to define and an awfully fun thing to have opinions about.
HTML-Ipsum
One-click copy to clipboard access to Lorem Ipsum text that comes wrapped in a variety of HTML.
Bookshelf
Hey Chris, what books do you recommend? These, young fertile mind, these.