Yeah, what's up, Richkoi? You trying to give us a good name?
If you get a good reputation, you might forget to become a raving hypster.... You might generate business the old fashioned way - gasp - good service !
This is the 21st century, man!
---------------------------------
Okay, I got this from 'imposter.org' but I tried to go to his site and it is moved/gone/404 error. However, it was provided free for download in a zip, and I will try to find the original on a backup disc. For now:
1.) - save this code as 'styleswitcher.js'
Quote:
function setActiveStyleSheet(title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
}
function getActiveStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
}
return null;
}
function getPreferredStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1
&& a.getAttribute("rel").indexOf("alt") == -1
&& a.getAttribute("title")
) return a.getAttribute("title");
}
return null;
}
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
window.onload = function(e) {
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
}
window.onunload = function(e) {
var title = getActiveStyleSheet();
createCookie("style", title, 365);
}
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
|
2.) here is the relevent code from from the head section of the page I got from imposter:
Quote:
<meta name="description" content="THE IMPOSTER ::: THE 'About theimposter.org' page :::" />
<meta name="keywords" content="THE IMPOSTER, carl durbridge, durbridge, web design, css, weblog, blog, imposter, fuzzynet, templates , examples, independent, web author" />
<meta name="AUTHOR" content="Carl Durbridge" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="alternate stylesheet" type="text/css" href="css/orange.css" title="orange" />
<link rel="alternate stylesheet" type="text/css" href="css/green.css" title="green" />
<link rel="alternate stylesheet" type="text/css" href="css/slim.css" title="slim" />
<script type="text/javascript" src="styleswitcher.js"></script>
|
3.)Here is rest, with original comments:
Quote:
</head>
<body onload="hideall();">
<div class="conttop">
<div class="boxes">
<div id="switchbox">
<!-- This is where we link to our alternate style sheets.
('default') is the initial style sheet loaded. This is the only sheet not named in the head
All the alternate sheets need to have the bracketed names matched to
the titled names in the head of the document -->
Default
Orange
<a href="#" onclick="setActiveStyleSheet('green'); return false;" title="Big Green">Big
Green</a> Slim
</div>
</div>
</div>
|
What I did is put the 4 stylesheets in a folder 'css' and the sheets are switched with the links. The changes are save in a cookie so that all the documents/pages use the 'user preference' they have chosen.
I will try to get the page cleaned up back to original, and just zip everything for you. It is easier when you see it in action to work with.
I am far from able to write my own scripts, I have been learning through cut'n'paste, and working with templates. I get around with javascript, perl, and php. Slowly the commands and assigning functions is coming to me, I am like php~pro, I guess - if I may be so bold, I want to be a programmer and concentrate on java, xml (soap, web services) and delphi or a C language.
What I am saying is that lot's can be done without knowing the language, but php/MySQL would still be pretty handy in the meantime.
-----------------------
I have some php scripts that I got from tutorials, they are more involved than using the javascript switcher, and one of them is a browser detect to serve appropriate CSS for different browsers.
I will get them for you, and the links to the tutes. Codewalker, phpKitchen, and DevShed, I think.