Changing the Background Colour

Click to view
Click to view

Put this code into your page:

<html>
<head>

<style>
.text
{
FONT: 10pt arial;
COLOR: black
}
</style>

<script language="JavaScript">
<!--

var backColor = new Array(); // don't change this

// Enter the colors you wish to use. Follow the
// pattern to use more colors. The number in the
// brackets [] is the number you will use in the
// function call to pick each color.

backColor[0] = '#ccffff';
backColor[1] = '#ccffcc';
backColor[2] = '#ffffcc';
backColor[3] = '#FFFFFF';

// Do not edit below this line.
//-----------------------------

function changeBG(whichColor){
document.bgColor = backColor[whichColor];
}

//-->
</script>

</HEAD>

<BODY>

<br><br><br>
<center>
<TABLE width="150" border="0" cellpadding="0" cellspacing="0" bgcolor=#F5F4E0>
<tr>
<td colspan=3><img src=images/spacer.gif height=10></td>
</tr>
<tr>
<td><img src=images/spacer.gif width=10></td>
<td bgcolor=white align=center><center>
<form name="choiceForm">
<table border=0 cellpadding="0" cellspacing="3">
<tr>
<td valign="top" width=175><center>
<!--Changing bg color with mouseOver.
Set the number in the () in the changeBG() function
to the number of the color in the brackets in the
backColor[] array to select a given color.//-->

<font class=text><b>Change the Background colour with a mouseOver:</b></font><br><br>
<a href="#" onMouseOver="javascript:changeBG(0)" class=text>Change 1</a><br>
<a href="#" onMouseOver="javascript:changeBG(1)" class=text>Change 2</a><br>
<a href="#" onMouseOver="javascript:changeBG(2)" class=text>Change 3</a><br>
<a href="#" onMouseOver="javascript:changeBG(3)" class=text>Change 4</a><br><br>

<!--Changing bg color with a mouse click.
Set the number in the () in the changeBG() function
to the number of the color in the brackets in the
backColor[] array to select a given color.//-->

<font class=text><b>Change the Background colour with a mouse click:</b></font><br><br>
<a href="javascript:changeBG(0)" class=text>Change 1</a><br>
<a href="javascript:changeBG(1)" class=text>Change 2</a><br>
<a href="javascript:changeBG(2)" class=text>Change 3</a><br>
<a href="javascript:changeBG(3)" class=text>Change 4</a><br>
</center></td>
</tr>
</table>
</form>
</center>
</td>
<td><img src=images/spacer.gif width=10></td>
</tr>
<tr>
<td colspan=3><img src=images/spacer.gif height=10></td>
</tr>
</table>
</center>

</body>
</html>


Related Articles

  • Colour Theory
    The 12 part colour wheel below is based on the three primary colours ( Red, Yellow and Blue ) placed evenly around a circle. Between the three primaries are the secondary colours (Green, Orange and Violet) which are mixtures of the two primaries they sit between...
  • Changing the Background Colour
    Yet another snippet of JavaScript code, folks. This time well be using JavaScript to change a background color with a MouseOver and a mouse click.
  • Web Colour Combinations
    What colour combination should I use in my website and how it will help your visitors on the long run.
  • Guidelines for Using Colour
    Colour is one of the designers best tools. There are lots of ways to use it to help communicate a message. Colour can carry meaning, express personality, differentiate, frame, and highlight content...
  • Neon Text
    Displays a sentence, changing its colour one letter at a time, from the start colour, to your chosen colour and back again. The script can be modified to change the message, colours and animation change.
  • Designing for Clarity
    Once you have your content, arranged it into a likely architecture, and worked out where it will sit on the page, youre ready to design the display layer. The goal is to arrange various elements on screen to maximise the users chance of using the site successfully...
  • Earn on Your Website - AdSense Basics, Advices and Tips
    This tutorial will help You start with Google AdSense. Some basic informations, advices and tips.
  • Website Checklist
    These topics represent the most common criticisms I have about sites Im asked to review - both on the Pegaweb forums, and through emails I receive.
  • The Key To Effective Web Site Design
    The key to effective web site design is good planning. Without planning and organisation, you will end up with chaos. Once you have a design plan, content is the next consideration. This applies equally to new and existing web sites. To create your plan for a new or existing site, sit down and co...
  • 8 Tips For Designing A Great Website
    Square buttons, round buttons, flashy buttons

Contact Web Design Outsource and get started today

Need Website Designing, Development, Redesigning, Maintenance and SEO services or help growing your company's web presence? Request a free Quote Now.