I want to load one of 4 random stylesheets everytime someone visits my page...I've been putzing around with java for the past 3 hours with little success and I'm not sure my server space supports php (its university space) so if anyone has a script or can fix my java plz help
var style=Math.floor(Math.random()*5);
if (style=1) {
document.write('<link rel="stylesheet" href="css/burg.css" type="text/css">');
}
else if (style=2) {
document.write('<link rel="stylesheet" href="css/darkblue.css" type="text/css">');
}
else if (style=3) {
document.write('<link rel="stylesheet" href="css/lightblue.css" type="text/css">');
}
else {
document.write('<link rel="stylesheet" href="css/green.css" type="text/css">');
}// End -->*/
thanks,
Chris
Re: How can I load a random stylesheet
This works for me ...
<script>
function chooseStyle() {
var css = new Array('blue','red','green');
var i = Math.floor(Math.random()*css.length);
var style = "css/"+css[i]+".css";
return style;
}
document.write('<link rel="stylesheet" href="'+chooseStyle()+'" type="text/css">');
</script>
Re: How can I load a random stylesheet
That is not java.
How can I load a random stylesheet
Thanks a ton, that worked perfectly....
Yeah I know my Java script is beyond terrible, I learned basic Java 3 years ago but never java script and I was trying to learn it last night at 4 in the morning, and I figured I'd include it just so it was easier to see what I was trying to do.
Thanks again,
Chris
How can I load a random stylesheet
I finished the site (gotta write more content and fix up grammer) for the most part incase you want to see how I applied ur script.
How can I load a random stylesheet
Nice. 
How about a nice slice of doctype pie? Try it. It's delicious.
How can I load a random stylesheet
that blue style has gotta go.

