Welcome to Jokes2000. Tips for improving your website: Graphic, HTML and javascript A fine collection of cartoons Jokes jokes jokes - get a good laugh Joke of the day and mailing list Table of contents
Jokes2000.com Jokes2000.com
 

Fading Background Up One Level.

With javascript 1.1, you can fade the backgroundcolor from one color to another. It is a nice effect, but you cannot use it in combination with a wallpaper. The effect works with Netscape Navigator 3+ and Microsoft Internet Explorer 4+. See it in action.

<script language="javascript1.1" type="text/javascript">
<!--
function makearray(n) 
{ this.length = n;
  for(var i = 1; i <= n; i++) this[i] = 0;
  return this;
}

hexa = new makearray(16);
for(var i = 0; i < 10; i++) hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

function hex(i)
{ if (i < 0) return "00";
  else if (i > 255) return "ff";
  else return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}

function setbgColor(r, g, b) 
{ var hr = hex(r); var hg = hex(g); var hb= hex(b);
  document.bgColor = "#"+hr+hg+hb;
}

function fade(sr, sg, sb, er, eg, eb, step)
{ for(var i = 0; i <= step; i++) 
  { setbgColor(
      Math.floor(sr * ((step-i)/step) + er * (i/step)),
      Math.floor(sg * ((step-i)/step) + eg * (i/step)),
      Math.floor(sb * ((step-i)/step) + eb * (i/step)));
  }
}

fade(0,0,0,255,255,255,200);
//-->
</script>


Change the parameters of the function fade(). sr,sg,sb defines the RGB value to start with. er,eg,eb defines the RGB value to end with. step is the speed. Higher value, slower fading.


Affiliate Sites: Funny Videos | Fight Videos | Free Arcade Games


welcome | cartoons | jokes | daily jokes | sitemap | search | feedback | what's new

Copyright © 1997-2007 Real Comedy Inc.