Start off by making all your stylesheets external. It might take a while, or it might take one cut-paste, its upto your template. Now, link to them by using the <link>
tags. The syntax for the tag is as follows:
<link rel="[1]" type="text/css" title="[2]" href="[3]">
where:
[1]: eitherstylesheet
oralternate stylesheet
. The one holding thestylesheet
value will be the default stylesheet. [2]: the title of your stylesheet so that it can be called from the script. [3]: the path to your stylesheet.
Now, put in this function in the head part of your template within <script></script>
tags:
function change_css(title) {
var i, a = document.getElementsByTagName("link"), b;
for(i=0;i<a.length;i++) {
if(a[i].getAttribute("rel").indexOf("style") != -1 && a[i].getAttribute("title")) {
a[i].disabled = true;
if(a[i].getAttribute("title") == title) a[i].disabled = false;
}
}
}
There! You're done with the hard part! Now, all you have to do is make links which will load in the different stylesheets! The link will look like this:
<a href="javascript:change_css('[4]')">Link Text</a>
where:
[4]: the title of the stylesheet you want to load.Hence, if there is a
<link>
tag with the title set to "Print" (for a printer friendly look), your link will look like this:
<a href="javascript:change_css('Print')">Print This</a>
Remember! The stylesheet is applied to the whole page. So if that link is executed on the main page, your entire main page will get styled accordingly. I'd suggest making those links appear only on your post pages using Blogger conditional tags. I don't know who might want to print out a while main page anyway :P
Simple? Good! This method can be used for many other things. In case you want to make several stylesheets for your viewers to pick from, the same method can be used. Let your imagination run wild! :)