Version compl�te: jsB@nk » Arrière-plan » Background Color Changer
URL: https://www.javascriptbank.com/background-color-changer-francis.html
Permet le réglage de la fenêtre du couleur de fond via rouge, vert, bleu et la couleur des boutons. Cliquez sur une bouton de modifier manuellement la valeur de couleur et cliquez sur Démarrer bouton flash à l'arrière-plan.
Version compl�te: jsB@nk » Arrière-plan » Background Color Changer
URL: https://www.javascriptbank.com/background-color-changer-francis.html
<SCRIPT language=Javascript> <!--/* This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com*/ var timerID = null var timerRunning = false var pmax=0//set max to the point where user stops. var aColor=['']//use this array if you want to keep a record of the colors hex values. var c=0 var max=0; function init(){ max=parseInt(document.colors.nmb.value)//maximum number of colors to step through if (isNaN(max)){ alert(document.colors.nmb.value+' is not a numerical value')document.colors.nmb.focus()} else startup() } function stopclock(){ if(timerRunning) clearTimeout(timerID); timerRunning = false; } function startclock(){ stopclock(); } function startup(){ /* change the values as need be. i.e. To see mostly blue set the maximum use: bb=255 for low red content in color use: rr=parseInt(Math.random()*70) for no green at all in color use: gg=0These can all be switch about as necessary */ c++ if (c > max) return (true); pmax++ rr=parseInt(Math.random()*255) gg=parseInt(Math.random()*255) bb=parseInt(Math.random()*255) document.colors.rr.value=rr document.colors.gg.value=gg document.colors.bb.value=bb setbgcolor(rr,gg,bb,c) } function setbgcolor(rr,gg,bb,nIndex){ var xcolor='#'+Hexconv(rr)+Hexconv(gg)+Hexconv(bb) aColor[nIndex]=xcolor document.colors.cr.value=xcolor document.bgColor=xcolor timerID=setTimeout("startup()",50) timerRunning = true } function Hexconv(nValue){ var aHex = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'] var n =nValue/16 var n_=nValue%16 n=parseInt(n) n =((n <= 15) ? aHex[n] : Hexconv(n)) n_=((n_ <= 15) ? aHex[n_] : Hexconv(n_)) var nhex=n+n_ return(nhex) } function Dispcolors(){ // this function is only necessary if you use the array to store the hex values. var y=0; if ((pmax/10) >=1){ document.write('<table border=1><tr>') for (var x=1; x<=pmax; x++){ y=y+1 document.write('<td bgColor="'+aColor[x]+'">'+aColor[x]+'</td>'); if (y == 8){ document.write('</tr><tr>'); y=0 } } } else{ for (var x=1; x<=pmax; x++) document.write('<td bgColor="'+aColor[x]+'">'+aColor[x]+'</td>') } document.write('</tr></table>') document.write('<br><br><small><small>Copyright © 1999, by Demetrius Francis</small></small>'); } //--></SCRIPT><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<FORM name=colors><CENTER><TABLE width="30%"> <TBODY> <TR> <TD align=right><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 9pt; FONT-WEIGHT: bold; TEXT-ALIGN: left">Loops:</SPAN></TD> <TD align=left><INPUT name=nmb size=7></TD></TR> <TR> <TD align=right><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 9pt; FONT-WEIGHT: bold; TEXT-ALIGN: left">Red:</SPAN></TD> <TD align=left><INPUT name=rr size=7></TD></TR> <TR> <TD align=right><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 9pt; FONT-WEIGHT: bold; TEXT-ALIGN: left">Green:</SPAN></TD> <TD><INPUT name=gg size=7></TD></TR> <TR> <TD align=right><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 9pt; FONT-WEIGHT: bold; TEXT-ALIGN: left">Blue:</SPAN></TD> <TD><INPUT name=bb size=7></TD></TR> <TR> <TD align=right><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 9pt; FONT-WEIGHT: bold; TEXT-ALIGN: left">Color:</SPAN></TD> <TD><INPUT name=cr size=12></TD></TR> <TR> <TD align=right><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 9pt; FONT-WEIGHT: bold; TEXT-ALIGN: left">Choices:</SPAN></TD> <TD><INPUT name=stop onclick=stopclock() type=button value=Stop!> <INPUT name=start onclick=init() type=button value=Start!> <INPUT name=clear type=reset value=Clear!> <INPUT name=list onclick=Dispcolors() type=button value=List!> </TD></TR> <TR> <TD align=left colSpan=2><SPAN style="FONT-FAMILY: Arial; FONT-SIZE: 9pt; FONT-WEIGHT: bold; TEXT-ALIGN: left"><BR>1. Enter the number of colors to generate (loops).<BR>2. Click the Start button.<BR>3. Click the List button to see results. </SPAN></TD></TR></TBODY></TABLE></CENTER></FORM><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->