Does anyone know a way either through javascript or DHTML to have your style sheets change automatically upon a certain date or season.
I've seen switchers that work with buttons, and I've seen scripts that can change page backgrounds based on months or seasons, but I cannot find a way to do style sheets automatically.
WARNING: I'm a beginner, at best, when it comes to javascript. My forte lies in HTML and CSS.
Any help is greatly appreciated.Since seasons are the same for everyone do it server side.If I don't know javascript, that still doesn't solve my problem. It doesn't matter, server side or client side, if I don't know what it takes to do it.
So does ANYONE ELSE have any ideas?
Thanks.Here's a simple style changer in PHP: <!-- m --><a class="postlink" href="http://forums.webdeveloper.com/showthread.php?s=&threadid=14661#post77670Okay..">http://forums.webdeveloper.com/showthre ... 7670Okay..</a><!-- m -->. I sort of understand what that PHP script does, but how can I get it to work for seasonal changes? I'm putting together a website for a client that wants to run seasonal specials for their merchandise. I've designed the entire page using style sheets instead of tables and when the season's change (approx - know it don't be to the minute exactly) I want the script to call the proper style sheet.
Again, though, scripting languages aren't my strong suit. Explain it to me as though I were an idiot...okay, maybe not an idiot but you get the picture.I think all you need to do with that script is to divide 31536000 by 4. That will give you a new style every 4 months.
31536000
/ 4
-----------
7884000Pretty smart idea. You're way ahead of me on that one. I'll give it a try. Thanks.Actually, that will just allow the cookie to expire. The original script was meant to be used to allow users to change their stylesheets. If you want to load a different stylesheet based on the time of year, it would be much easier, as all you'd have to do is use PHP's date() (<!-- m --><a class="postlink" href="http://us4.php.net/manual/en/function.date.php">http://us4.php.net/manual/en/function.date.php</a><!-- m -->) functions to get the current month and display the corresponding stylesheet.Here's the gist of what I'm talking about. Some tweaking would give you better results if you are looking to base it on seasons, though.
<?PHP
$month = date("n"); # get month (1-12)
if ($month < 4) { # 1-3
echo "first stylesheet";
}
else if ($month > 3 && $month < 7) { # 4-6
echo "second stylesheet";
}
else if ($month > 6 && $month < 10) { # 7-9
echo "third stylesheet";
}
else { # 10-12
echo "fourth stylesheet";
}
?>Thanks again.You bet. I have a somewhat unrelated question. Let's say I have two stylesheets and after the user picks the second one, will there be a slight, but noticable change in the layout as it goes from the default layout to the newer one if you use a PHP style sheet switcher? I ask because I have gone to meyer's website and picked different style sheets only to see this switch like effect happening. I know his style sheet switcher is done via JavaScript. I also have a 56K connection so page loads will be slower than for a high speed connection.No, there shouldn't be. You can see a demo of the PHP version running at <!-- m --><a class="postlink" href="http://www.webdevfaqs.com/">http://www.webdevfaqs.com/</a><!-- m -->. The only thing you will be likely to notice would be images loading...Originally posted by Vladdy
Since seasons are the same for everyone do it server side.
am i interpreting this wrong or did you mean that when it is Winter in England, then it is Winter in Australia?
that's a bit wrong aint it?
ah well!Originally posted by giggledesign
am i interpreting this wrong or did you mean that when it is Winter in England, then it is Winter in Australia?
that's a bit wrong aint it?
ah well!
Nah, them Aussies just have hot Winters down there.
and cold summers?
I've seen switchers that work with buttons, and I've seen scripts that can change page backgrounds based on months or seasons, but I cannot find a way to do style sheets automatically.
WARNING: I'm a beginner, at best, when it comes to javascript. My forte lies in HTML and CSS.
Any help is greatly appreciated.Since seasons are the same for everyone do it server side.If I don't know javascript, that still doesn't solve my problem. It doesn't matter, server side or client side, if I don't know what it takes to do it.
So does ANYONE ELSE have any ideas?
Thanks.Here's a simple style changer in PHP: <!-- m --><a class="postlink" href="http://forums.webdeveloper.com/showthread.php?s=&threadid=14661#post77670Okay..">http://forums.webdeveloper.com/showthre ... 7670Okay..</a><!-- m -->. I sort of understand what that PHP script does, but how can I get it to work for seasonal changes? I'm putting together a website for a client that wants to run seasonal specials for their merchandise. I've designed the entire page using style sheets instead of tables and when the season's change (approx - know it don't be to the minute exactly) I want the script to call the proper style sheet.
Again, though, scripting languages aren't my strong suit. Explain it to me as though I were an idiot...okay, maybe not an idiot but you get the picture.I think all you need to do with that script is to divide 31536000 by 4. That will give you a new style every 4 months.
31536000
/ 4
-----------
7884000Pretty smart idea. You're way ahead of me on that one. I'll give it a try. Thanks.Actually, that will just allow the cookie to expire. The original script was meant to be used to allow users to change their stylesheets. If you want to load a different stylesheet based on the time of year, it would be much easier, as all you'd have to do is use PHP's date() (<!-- m --><a class="postlink" href="http://us4.php.net/manual/en/function.date.php">http://us4.php.net/manual/en/function.date.php</a><!-- m -->) functions to get the current month and display the corresponding stylesheet.Here's the gist of what I'm talking about. Some tweaking would give you better results if you are looking to base it on seasons, though.
<?PHP
$month = date("n"); # get month (1-12)
if ($month < 4) { # 1-3
echo "first stylesheet";
}
else if ($month > 3 && $month < 7) { # 4-6
echo "second stylesheet";
}
else if ($month > 6 && $month < 10) { # 7-9
echo "third stylesheet";
}
else { # 10-12
echo "fourth stylesheet";
}
?>Thanks again.You bet. I have a somewhat unrelated question. Let's say I have two stylesheets and after the user picks the second one, will there be a slight, but noticable change in the layout as it goes from the default layout to the newer one if you use a PHP style sheet switcher? I ask because I have gone to meyer's website and picked different style sheets only to see this switch like effect happening. I know his style sheet switcher is done via JavaScript. I also have a 56K connection so page loads will be slower than for a high speed connection.No, there shouldn't be. You can see a demo of the PHP version running at <!-- m --><a class="postlink" href="http://www.webdevfaqs.com/">http://www.webdevfaqs.com/</a><!-- m -->. The only thing you will be likely to notice would be images loading...Originally posted by Vladdy
Since seasons are the same for everyone do it server side.
am i interpreting this wrong or did you mean that when it is Winter in England, then it is Winter in Australia?
that's a bit wrong aint it?
ah well!Originally posted by giggledesign
am i interpreting this wrong or did you mean that when it is Winter in England, then it is Winter in Australia?
that's a bit wrong aint it?
ah well!
Nah, them Aussies just have hot Winters down there.
and cold summers?