Ryan's District
November 22, 2008, 10:01:24 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Ryan's District Lottery: Claim your ticket or check
Jackpot details  
 
   Home   Help Search Chat Calendar Chess Shop Login Register  
Digg This!
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: Background effects - A cool JavaScript tip  (Read 3745 times)
0 Members and 1 Guest are viewing this topic.
ben2ong2
Quality Poster
Paid
Hero Member
*****

Reputation: 17
Offline Offline

Gender: Male
Posts: 2374
9976.80 RD$

View Inventory
Send Money to ben2ong2

View Profile Awards
« on: October 04, 2006, 02:58:44 AM »


Here is a cool Javascript tip that will change the background color over time. With a few modifications, you can use this tip to display all the colors of the rainbow in the background. This tip describes how to create a fading web page background.

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
  • ;
   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.



Logged

You are not allowed to view links.
Register or Login
Free Paid Survey & Home Business Resources.

You are not allowed to view links.
Register or Login
Free Article Directory | Quality Content
Ryan's District
« on: October 04, 2006, 02:58:44 AM »

 Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Archive - WAP2 - WAP - imode
Sponsors: RAYAN.tv
-

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 6.14 seconds with 31 queries.

Google visited last this page November 20, 2008, 04:39:08 PM