How I change the BG Color?

How I change the BG Color?

Some people have asked how I change the background colour on my websites… Well there are two ways. I uses Dynamic linking to separate style-sheets here, on brennanmceachran.com, and on every other site I just use javascript. Below are the codes

In PHP:

$d=date(“D”);
if ($d==”Mon”){ ?>
<link href=”UrlToStyleSheet” rel=”stylesheet” type=”text/css” />
<?php } ?>
Pretty self explainatory… Set variable $d to the day of the week. and if that’s a Monday it links the Monday style sheet up. You can do this for all dates if you want. Read here if you want to explore more options of the PHP Date Function

In Javascript:

var random = Math.random();
var colors = 8;
var  randomcolor= Math.round(random * (colors-1)) + 1;bgs = new Array
bgs[1] = “3333cc” //blue
bgs[2] = “9933cc” //purple
bgs[3] = “cc3333″ //red
bgs[4] = “33cc33″ //green
bgs[5] = “99cc33″ //lime green
bgs[6] = “cccc33″ //yellow
bgs[7] = “cc9933″ //orange
bgs[8] = “cc6633″ //orange-red
var bg = bgs[randomcolor];
document.write(‘<body bgcolor=”#’ + bg + ‘”>’)

Here’s how I do it with javascript. There are more ways of doing something like this… but I like to change up the colors all the time and this way allows me to quickly do so.