Website Design Edmonton       Website Design Feedback       Website Design Sitemap     Contact Website Design Company
Website Designers R Us - Home
Background effects A cool JavaScript tip

Using the bgColor property of the JavaScript window object, we can change the background color. Here is the code:

var c = new Array("00", "11", "22", "33", "44", "55",
"66", "77", "88", "99", "AA", "BB", "CC", "DD", "EE", "FF");

x = 0;

function bg_eff()
   {
   col_val = "#FFFF" + c[x];
   document.bgColor=col_val;
   x++;
   if (x == 16)
      {
      clearInterval(change_bg);
      }
   }

change_bg = setInterval("bg_eff()", 250);

The color values are stored in an array c. The function bg_eff() assigns a color value to variable col_val and then sets the bgColor property to this value. The function is called after every 250 milliseconds using the setInterval() method. On each call to the function the value of variable x is increased by one. When x equals 15, the clearInterval method() is invoked that stops the setInternval() method.

Return to Listing

Website Designer R Us is the right company to get your job done professionally and cost effectively. We've seen the good, the bad, and the ugly, and we are here to help you by recommending the services that match your needs based on our knowledge of other website designers and web design companies whom can perform the type work you are needing.
 Home          ::             About Us          ::             Support            ::             Services            ::             Link Partners          ::             Contact

Copyright © 2006-2011 Website Designers R Us, a DOT Specialist Company. All rights reserved.