faqts : Computers : Programming : Languages : JavaScript : Document

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 18 people (94%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How to automatically modify background color daily
How to apply "day" value to automatically modify back color daily
How to automatically modify back color in IE5?

May 17th, 2000 05:42
Hiroto Sekine, Martin Honnen, http://www.all.co.nz/support/jpspell.htm


with IE5: Try below code. This might work for IE4 as well. 
function makeBackColor(){
	var i = 0;
	this[i++] = "#FFDEAD";
	this[i++] = "#FFEBCD";
	this[i++] = "#009999";
	this[i++] = "#CCC1B2";
	this[i++] = "#E8E2D6";
	this[i++] = "#8B0000";
	this[i++] = "#009900";
	this[i	] = null;
	this.length = i;
}
function makeTextColor(){
	var i = 0;
	this[i++] = "#228B22";
	this[i++] = "#800000";
	this[i++] = "#FFCC99";
	this[i++] = "#660000";
	this[i++] = "#00008B";
	this[i++] = "#FDF5E6";
	this[i++] = "#FFE4B5";
	this[i	] = null;
	this.length = i;
}
function todayColor(){
	var t = new Date();
	var day = t.getDay();
	var BC = new makeBackColor();
	var TC = new makeTextColor();
	with(oBody){
		runtimeStyle["background"] = BC[day];
		runtimeStyle["color"] = TC[day];
	}
}
<body OnLoad="todayColor();" id="oBody">