We have learnt how to add the colorful frame to the web page last article. Now we will learn how to make the twinkling background color in this article. When you enter a web page, the twinkling background color will give you a mystic feeling. Moreover, the twinkling background color will attract the viewers’ attention and the links with twinkling background color can attract more people to click the links. Now you may be interested in how to make the twinkling background color. It is easy, and just need four steps. Follow me.
|
First, open the original web page you have saved. The original web page is like the following picture.
|
Second, click the code button and open the code view. Then put the following blue text into the section between <head> and </head>.
- <script LANGUAGE="JavaScript">
- <!-- Hide from old browsers
- var Color= new Array(9);
- Color[1] = "ff";
- Color[2] = "ee";
- Color[3] = "dd";
- Color[4] = "cc";
- Color[5] = "bb";
- Color[6] = "aa";
- Color[7] = "99";
- Color[8] = "88";
- Color[9] = "77";
- Color[10] = "66";
- Color[11] = "55";
- Color[12] = "44";
- Color[13] = "33";
- Color[14] = "22";
- Color[15] = "11";
- Color[16] = "00";
- /* Do not display text on a fading background. Instead, let it
- fade in and out once or twice, then load a new page. */
- function fadeIn(where) {
- if (where >= 1) {
- document.bgColor="#" + Color[where] +"0000";
- where -= 1;
- setTimeout("fadeIn("+where+")", 15);
- } else {
- setTimeout('fadeOut(1)', 15);
- }
- }
- function fadeOut(where) {
- if (where < =16) {
- document.bgColor="#" + Color[where] +"0000";
- where += 1;
- setTimeout("fadeOut("+where+")", 15)
- } else {
- setTimeout("fadeIn(16)", 15);
- // window.location.href="http://www.donotyet.com/";
- }
- }
- // Unhide -->
- </script>
The color[] is to definite the fading background colors. You can change them into other colors. setTimeout is to definite the twinkling time. function fadeout is to definite the fade function. These codes are easy to understand.
Third, modify the body sentence. The final body sentence should be like this: <body onLoad=fadeIn(16)>. When you open the document, the web page will rule out the fadeIn(16) function. The spilt view is like the following picture.
Fourth, go back to the design view and save the document. Then press F12 key to preview the effect in the Internet Explorer. Like the following picture. You can see the back color fading from red to black. If you are discontent with the twinkling color, you can change it to others.
|
|
Now the web page with twinkling background color is ready. You can change the color in to others. But the twinkling color should be fit for the whole website. Or the twinkling background color will look unharmonious.
For help, advice, tips and tricks, challenges, feel free to visit our
or Submit your good resource to share.
Reminder: Unless stated otherwise, all resources published on this site are NOT for commercial use. To use any resource from this site for commercial purposes, please contact the author.

