Flashing colors when opening page

Updated: 01/31/2019 by Computer Hope
flashing colors when opening page

Example

Before the example page loads, you'll see multiple colors. Hit refresh 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>