HOME  >>>  HTML整理ノート  >>> DHTML --  基本編  応用編

カラフル・テキスト

D Y N A M I C H T M L

  

(ポイント)配列要素(この場合はcolor名)をランダムに選択 

  

Sample Source......................................................................>>>

<STYLE TYPE="text/css"><!--
   SPAN {font-size:24pt;font-family:"Arial Black","MS Sans Serif";}
--></STYLE>
<SCRIPT language="JavaScript"><!--
 function TxtColor(){
   fc = new Array("red","black","blue","green","yellow","magenta",
                  "brown","maroon","gray","pink","cyan");
   for(i=0;i<=11;i++){
     document.all("sp"+i).style.color = fc[Math.round((fc.length-1)*Math.random())];
   }
   dv.style.borderColor = fc[Math.round((fc.length-1)*Math.random())];
   setTimeout("TxtColor()",1000);
 }
//--></SCRIPT>
</HEAD>

<BODY onload="TxtColor()">
 <DIV id="dv" style="width:380;border:thin solid">
   <SPAN id="sp0">D</SPAN>
   <SPAN id="sp1">Y</SPAN>
   <SPAN id="sp2">N</SPAN>
   <SPAN id="sp3">A</SPAN>
   <SPAN id="sp4">M</SPAN>
   <SPAN id="sp5">I</SPAN>
   <SPAN id="sp6">C</SPAN>
   <SPAN id="sp7">・</SPAN>
   <SPAN id="sp8">H</SPAN>
   <SPAN id="sp9">T</SPAN>
   <SPAN id="sp10">M</SPAN>
   <SPAN id="sp11">L</SPAN>
</DIV>


end(最終更新:12/11/16)