SHARE
Facebook X Pinterest WhatsApp

So, You Want A Background JavaScript, Huh?

Written By
thumbnail
Joe Burns
Joe Burns
Jan 4, 2005




Thanks to Josh Robbins for this script.

Please note: This is a background JavaScript and as such, it often doesn’t play well with background images. You may not be able to have a background
image on your page if you use this script.

     Okay, here we go. This one is super simple AND you can actually play around with it to change the flow of the colors. First off, the script. Just cut and paste what’s below. Paste the whole deal without changing the configuration or the spacing between the items. That can corrupt it. Here you go:




The Script Is Here



     If you look closely, you’ll see that there are two scripts, one right after the other. I don’t quite understand why, but you need both of them just as I offer it. Grab the whole thing — or both things, as it were.

     Paste the script right under your <HTML> command, before the title commands. In this position it will run before putting up any text. Then write the rest of your page as you would any other.

Changing Colors

     Look at the second of the two scripts where it states:


// black to black (pause)

bgChanger(“000000″,”000000”,25);

     Notice it has names of colors and then those strange six-number codes. Those are hex codes. You’ll find a ton of them (140 to be exact) in my So, You Want A Basics Color Code, Huh? tutorial. Now, I don’t know how much you can actually play with this script — I would keep a clean copy handy — but I changed the final codes so it ended on white rather than black and it worked. I don’t believe you have to change the names of the colors. It worked without me doing it one time. So, try a few other combinations and please let me know what happened. I’ll pass the word along.

     Man, these tutorials are getting too easy! I should start bringing Plato into them. He was big into the Net. I’ll bet you didn’t know that.

Recommended for you...

The Revolutionary ES6 Rest and Spread Operators
Rob Gravelle
Aug 23, 2022
Ahead of Time (AOT) Compilation in Angular
Tariq Siddiqui
Aug 16, 2022
Converting a JavaScript Object to a String
Rob Gravelle
Aug 14, 2022
Understanding Primitive Type Coercion in JavaScript
Rob Gravelle
Jul 28, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.