Flashing colors when opening page

Example

Before the example page loads, you will see a multitude of colors. Hit refresh if you would like to see it again.

Source code

<script type="text/javascript">
function bgChanger (end) {
document.getElementsByTagName("body")[0].style.backgroundColor = "#" + end;
}
//red
setTimeout(function() { bgChanger("FF0000")}, 0);
//black
setTimeout(function() { bgChanger("000000")}, 100);
//purple
setTimeout(function() {bgChanger("AA00EE")}, 200);
//green
setTimeout(function() {bgChanger("00FF00")}, 300);
//blue
setTimeout(function() {bgChanger("0000FF")}, 400);
//gray
setTimeout(function() {bgChanger("CCCCCC")}, 500);
//white (pause)
setTimeout(function() {bgChanger("FFFFFF")}, 600);
</script>

  • Category
  • Cool Tricks
  • Related pages
  • HTML Help
  • Solved?
  • Were you able to locate the answer to your question?