s1980
Sep 2nd 2008, 6:30 am
Hi,
I am trying to work out a code where I can change the background colour of an HTML page via external JS page. Please note that I will be using different HTML pages with different colours so have to use Arrays. Here is what I have so far!!!
here is my function,
<script language="JavaScript">
var backColor = new Array();
backColor[0] = '#000000';
backColor[1] = '#111111;
backColor[2] = '#222222';
backColor[3] = '#333333';
function changeBG(whichColor){
document.bgColor = backColor[whichColor];
}
</script>
What I need is to apply changeBG function (which is on an external JS file) to my HTML page without applying actions like onClick or onMouse over.
Any help would be greatly appreciated!
I am trying to work out a code where I can change the background colour of an HTML page via external JS page. Please note that I will be using different HTML pages with different colours so have to use Arrays. Here is what I have so far!!!
here is my function,
<script language="JavaScript">
var backColor = new Array();
backColor[0] = '#000000';
backColor[1] = '#111111;
backColor[2] = '#222222';
backColor[3] = '#333333';
function changeBG(whichColor){
document.bgColor = backColor[whichColor];
}
</script>
What I need is to apply changeBG function (which is on an external JS file) to my HTML page without applying actions like onClick or onMouse over.
Any help would be greatly appreciated!