September 2, 200818 yr 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!
September 11, 200818 yr You could also do it in a link like <a href="java script:changeBG(colour)">Change Background</a>
Create an account or sign in to comment