How to you can randomly change color of the background of your website
->
Here is how you can randomly change color of the background of your website.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <script> // Select fade-effect below: // Set 1 if the background may fade from dark to medium // Set 2 if the background may fade from light to medium // Set 3 if the background may fade from very dark to very light light // Set 4 if the background may fade from light to very light // Set 5 if the background may fade from dark to very dark var fade_effect=3 // What type of gradient should be applied Internet Explorer 5x or higher? // Set "none" or "horizontal" or "vertical" var gradient_effect="horizontal" // Speed higher=slower var speed=60 /////////////////////////////////////////////////////////////////////////// // CONFIGURATION ENDS HERE /////////////////////////////////////////////////////////////////////////// var browserinfos=navigator.userAgent var ie4=document.all&&!document.getElementById var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/) var ns4=document.layers var ns6=document.getElementById&&!document.all var opera=browserinfos.match(/Opera/) var browserok=ie4||ie5||ns4||ns6||opera if (fade_effect==1) { var darkmax=1 var lightmax=127 } if (fade_effect==2) { var darkmax=127 var lightmax=254 } if (fade_effect==3) { var darkmax=1 var lightmax=254 } if (fade_effect==4) { var darkmax=190 var lightmax=254 } if (fade_effect==5) { var darkmax=1 var lightmax=80 } var hexc = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F') var newred var newgreen var newblue var oldred var oldgreen var oldblue var redcol_1 var redcol_2 var greencol_1 var greencol_2 var bluecol_1 var bluecol_2 var oldcolor var newcolor var firsttime=true var stepred=1 var stepgreen=1 var stepblue=1 function setrandomcolor() { var range=(lightmax-darkmax) if (firsttime) { newred=Math.ceil(range*Math.random())+darkmax newgreen=Math.ceil(range*Math.random())+darkmax newblue=Math.ceil(range*Math.random())+darkmax firsttime=false } oldred=Math.ceil(range*Math.random())+darkmax oldgreen=Math.ceil(range*Math.random())+darkmax oldblue=Math.ceil(range*Math.random())+darkmax stepred=newred-oldred if (oldred>newred) {stepred=1} else if (oldred<newred) {stepred=-1} else {stepred=0} stepgreen=newgreen-oldgreen if (oldgreen>newgreen) {stepgreen=1} else if (oldgreen<newgreen) {stepgreen=-1} else {stepgreen=0} stepblue=newblue-oldblue if (oldblue>newblue) {stepblue=1} else if (oldblue<newblue) {stepblue=-1} else {stepblue=0} fadebg() } function fadebg() { if (newred==oldred) {stepred=0} if (newgreen==oldgreen) {stepgreen=0} if (newblue==oldblue) {stepblue=0} newred+=stepred newgreen+=stepgreen newblue+=stepblue if (stepred!=0 || stepgreen!=0 || stepblue!=0) { redcol_1 = hexc[Math.floor(newred/16)]; redcol_2 = hexc[newred%16]; greencol_1 = hexc[Math.floor(newgreen/16)]; greencol_2 = hexc[newgreen%16]; bluecol_1 = hexc[Math.floor(newblue/16)]; bluecol_2 = hexc[newblue%16]; newcolor="#"+redcol_1+redcol_2+greencol_1+greencol_2+bluecol_1+bluecol_2 if (ie5 && gradient_effect!="none") { if (gradient_effect=="horizontal") {gradient_effect=1} if (gradient_effect=="vertical") {gradient_effect=0} greencol_1 = hexc[Math.floor(newred/16)]; greencol_2 = hexc[newred%16]; bluecol_1 = hexc[Math.floor(newgreen/16)]; bluecol_2 = hexc[newgreen%16]; redcol_1 = hexc[Math.floor(newblue/16)]; redcol_2 = hexc[newblue%16]; var newcolorCompl="#"+redcol_1+redcol_2+greencol_1+greencol_2+bluecol_1+bluecol_2 document.body.style.filter= "progid:DXImageTransform.Microsoft.Gradient(startColorstr="+newcolorCompl+", endColorstr="+newcolor+" GradientType="+gradient_effect+")" } else { document.bgColor=newcolor } var timer=setTimeout("fadebg()",speed); } else { clearTimeout(timer) newred=oldred newgreen=oldgreen newblue=oldblue oldcolor=newcolor setrandomcolor() } } if (browserok) { window.onload=setrandomcolor } </script> <font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
How to make your website have randomly change its background color
->
Here is how you can make your website have randomly change its background color.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <script> // Select fade-effect below: // Set 1 if the background may fade from dark to medium // Set 2 if the background may fade from light to medium // Set 3 if the background may fade from very dark to very light light // Set 4 if the background may fade from light to very light // Set 5 if the background may fade from dark to very dark var fade_effect=3 // What type of gradient should be applied Internet Explorer 5x or higher? // Set "none" or "horizontal" or "vertical" var gradient_effect="horizontal" // Speed higher=slower var speed=60 /////////////////////////////////////////////////////////////////////////// // CONFIGURATION ENDS HERE /////////////////////////////////////////////////////////////////////////// var browserinfos=navigator.userAgent var ie4=document.all&&!document.getElementById var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/) var ns4=document.layers var ns6=document.getElementById&&!document.all var opera=browserinfos.match(/Opera/) var browserok=ie4||ie5||ns4||ns6||opera if (fade_effect==1) { var darkmax=1 var lightmax=127 } if (fade_effect==2) { var darkmax=127 var lightmax=254 } if (fade_effect==3) { var darkmax=1 var lightmax=254 } if (fade_effect==4) { var darkmax=190 var lightmax=254 } if (fade_effect==5) { var darkmax=1 var lightmax=80 } var hexc = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F') var newred var newgreen var newblue var oldred var oldgreen var oldblue var redcol_1 var redcol_2 var greencol_1 var greencol_2 var bluecol_1 var bluecol_2 var oldcolor var newcolor var firsttime=true var stepred=1 var stepgreen=1 var stepblue=1 function setrandomcolor() { var range=(lightmax-darkmax) if (firsttime) { newred=Math.ceil(range*Math.random())+darkmax newgreen=Math.ceil(range*Math.random())+darkmax newblue=Math.ceil(range*Math.random())+darkmax firsttime=false } oldred=Math.ceil(range*Math.random())+darkmax oldgreen=Math.ceil(range*Math.random())+darkmax oldblue=Math.ceil(range*Math.random())+darkmax stepred=newred-oldred if (oldred>newred) {stepred=1} else if (oldred<newred) {stepred=-1} else {stepred=0} stepgreen=newgreen-oldgreen if (oldgreen>newgreen) {stepgreen=1} else if (oldgreen<newgreen) {stepgreen=-1} else {stepgreen=0} stepblue=newblue-oldblue if (oldblue>newblue) {stepblue=1} else if (oldblue<newblue) {stepblue=-1} else {stepblue=0} fadebg() } function fadebg() { if (newred==oldred) {stepred=0} if (newgreen==oldgreen) {stepgreen=0} if (newblue==oldblue) {stepblue=0} newred+=stepred newgreen+=stepgreen newblue+=stepblue if (stepred!=0 || stepgreen!=0 || stepblue!=0) { redcol_1 = hexc[Math.floor(newred/16)]; redcol_2 = hexc[newred%16]; greencol_1 = hexc[Math.floor(newgreen/16)]; greencol_2 = hexc[newgreen%16]; bluecol_1 = hexc[Math.floor(newblue/16)]; bluecol_2 = hexc[newblue%16]; newcolor="#"+redcol_1+redcol_2+greencol_1+greencol_2+bluecol_1+bluecol_2 if (ie5 && gradient_effect!="none") { if (gradient_effect=="horizontal") {gradient_effect=1} if (gradient_effect=="vertical") {gradient_effect=0} greencol_1 = hexc[Math.floor(newred/16)]; greencol_2 = hexc[newred%16]; bluecol_1 = hexc[Math.floor(newgreen/16)]; bluecol_2 = hexc[newgreen%16]; redcol_1 = hexc[Math.floor(newblue/16)]; redcol_2 = hexc[newblue%16]; var newcolorCompl="#"+redcol_1+redcol_2+greencol_1+greencol_2+bluecol_1+bluecol_2 document.body.style.filter= "progid:DXImageTransform.Microsoft.Gradient(startColorstr="+newcolorCompl+", endColorstr="+newcolor+" GradientType="+gradient_effect+")" } else { document.bgColor=newcolor } var timer=setTimeout("fadebg()",speed); } else { clearTimeout(timer) newred=oldred newgreen=oldgreen newblue=oldblue oldcolor=newcolor setrandomcolor() } } if (browserok) { window.onload=setrandomcolor } </script> <font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
How to make falling leaves appear in the background of your webpage
Here is how you can make the title of the your webpage scroll.
Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<!-- this script is from www.manycodes.com --> <script language="JavaScript1.2"> //Pre-load your image below! grphcs=new Array(6) Image0=new Image(); Image0.src=grphcs[0]="http://javascriptfreecode.com/images/barg.gif"; Image1=new Image(); Image1.src=grphcs[1]="http://javascriptfreecode.com/images/barg.gif" Image2=new Image(); Image2.src=grphcs[2]="http://javascriptfreecode.com/images/barg.gif" Image3=new Image(); Image3.src=grphcs[3]="http://javascriptfreecode.com/images/barg.gif" Image4=new Image(); Image4.src=grphcs[4]="http://javascriptfreecode.com/images/barg.gif" Image5=new Image(); Image5.src=grphcs[5]="http://javascriptfreecode.com/images/barg.gif" Amount=8; //Smoothness depends on image file size, the smaller the size the more you can use! Ypos=new Array(); Xpos=new Array(); Speed=new Array(); Step=new Array(); Cstep=new Array(); ns=(document.layers)?1:0; ns6=(document.getElementById&&!document.all)?1:0; if (ns){ for (i = 0; i < Amount; i++){ var P=Math.floor(Math.random()*grphcs.length); rndPic=grphcs[P]; document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+rndPic+"></LAYER>"); } } else{ document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">'); for (i = 0; i < Amount; i++){ var P=Math.floor(Math.random()*grphcs.length); rndPic=grphcs[P]; document.write('<img id="si'+i+'" src="'+rndPic+'" style="position:absolute;top:0px;left:0px">'); } document.write('</div></div>'); } WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight; WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth; for (i=0; i < Amount; i++){ Ypos[i] = Math.round(Math.random()*WinHeight); Xpos[i] = Math.round(Math.random()*WinWidth); Speed[i]= Math.random()*5+3; Cstep[i]=0; Step[i]=Math.random()*0.1+0.05; } function fall(){ var WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight; var WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth; var hscrll=(ns||ns6)?window.pageYOffset:document.body.scrollTop; var wscrll=(ns||ns6)?window.pageXOffset:document.body.scrollLeft; for (i=0; i < Amount; i++){ sy = Speed[i]*Math.sin(90*Math.PI/180); sx = Speed[i]*Math.cos(Cstep[i]); Ypos[i]+=sy; Xpos[i]+=sx; if (Ypos[i] > WinHeight){ Ypos[i]=-60; Xpos[i]=Math.round(Math.random()*WinWidth); Speed[i]=Math.random()*5+3; } if (ns){ document.layers['sn'+i].left=Xpos[i]; document.layers['sn'+i].top=Ypos[i]+hscrll; } else if (ns6){ document.getElementById("si"+i).style.left=Math.min(WinWidth,Xpos[i]); document.getElementById("si"+i).style.top=Ypos[i]+hscrll; } else{ eval("document.all.si"+i).style.left=Xpos[i]; eval("document.all.si"+i).style.top=Ypos[i]+hscrll; } Cstep[i]+=Step[i]; } setTimeout('fall()',20); } window.onload=fall //--> </script> <pre><font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font></pre> </pre>
How to make stars moving in background of your website
Here is how you can make stars moving in background of your website. Make your website the sky and have lots and lots of stars showing on it.
Put the code below within your site's <head> </head> tags. If you dont know how to implement this code into your site, please goto how to implement the code to your website
Code:
<pre><!-- this script is from www.manycodes.com --></pre> <body> <!-- STEP ONE: Insert the onLoad event handler into your BODY tag --> <BODY BGCOLOR="#000000" onLoad="fly()"> <!-- STEP TWO: Paste this code into the BODY of your HTML document --> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin SmallStars = 30; LargeStars = 10; SmallYpos = new Array(); SmallXpos = new Array(); LargeYpos = new Array(); LargeXpos = new Array(); Smallspeed= new Array(); Largespeed= new Array(); ns=(document.layers)?1:0; if (ns) { for (i = 0; i < SmallStars; i++) { document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,1,1'></LAYER>"); } for (i = 0; i < LargeStars; i++) { document.write("<LAYER NAME='ln"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFFF' CLIP='0,0,2,2'></LAYER>"); } } else { document.write('<div style="position:absolute;top:0px;left:0px">'); document.write('<div style="position:relative">'); for (i = 0; i < SmallStars; i++) { document.write('<div id="si" style="position:absolute;top:0;left:0;width:1px;height:1px;background:#fffff0;font-size:1px"></div>'); } document.write('</div>'); document.write('</div>'); document.write('<div style="position:absolute;top:0px;left:0px">'); document.write('<div style="position:relative">'); for (i = 0; i < LargeStars; i++) { document.write('<div id="li" style="position:absolute;top:0;left:0;width:2px;height:2px;background:#ffffff;font-size:2px"></div>'); } document.write('</div>'); document.write('</div>'); } WinHeight = (document.layers)?window.innerHeight:window.document.body.clientHeight; WinWidth = (document.layers)?window.innerWidth:window.document.body.clientWidth; for (i = 0; i < SmallStars; i++) { SmallYpos[i] = Math.round(Math.random() * WinHeight); SmallXpos[i] = Math.round(Math.random() * WinWidth); Smallspeed[i]= Math.random() * 5 + 1; } for (i = 0; i < LargeStars; i++) { LargeYpos[i] = Math.round(Math.random() * WinHeight); LargeXpos[i] = Math.round(Math.random() * WinWidth); Largespeed[i] = Math.random() * 10 + 5; } function fly() { var WinHeight = (document.layers)?window.innerHeight:window.document.body.clientHeight; var WinWidth = (document.layers)?window.innerWidth:window.document.body.clientWidth; var hscrll = (document.layers)?window.pageYOffset:document.body.scrollTop; var wscrll = (document.layers)?window.pageXOffset:document.body.scrollLeft; for (i = 0; i < LargeStars; i++) { LargeXpos[i] -= Largespeed[i]; if (LargeXpos[i] < -10) { LargeXpos[i] = WinWidth; LargeYpos[i] = Math.round(Math.random() * WinHeight); Largespeed[i] = Math.random() * 10 + 5; } if (ns) { document.layers['ln'+i].left = LargeXpos[i]; document.layers['ln'+i].top = LargeYpos[i] + hscrll; } else { li[i].style.pixelLeft = LargeXpos[i]; li[i].style.pixelTop = LargeYpos[i] + hscrll; } } for (i = 0; i < SmallStars; i++) { SmallXpos[i] -= Smallspeed[i]; if (SmallXpos[i] < -10) { SmallXpos[i] = WinWidth; SmallYpos[i] = Math.round(Math.random()*WinHeight); Smallspeed[i] = Math.random() * 5 + 1; } if (ns) { document.layers['sn'+i].left = SmallXpos[i]; document.layers['sn'+i].top = SmallYpos[i]+hscrll; } else { si[i].style.pixelLeft = SmallXpos[i]; si[i].style.pixelTop = SmallYpos[i]+hscrll; } } setTimeout('fly()', 10); } // End --> </script> <!-- Script Size: 3.79 KB --> <pre><font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font></pre>