<div class="codetitle"> <span><a style="CURSOR: pointer" data="72668" class="copybut" id="copybut72668" onclick="doCopy('code72668')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code72668"> <br><body bgcolor="#000000"> <br><div id="text" style="font-size:20px;">你好,这是一段改变文字大小和颜色的javascript代码</div> <br><script type="text/javascript"> <br>var size = 20; <br>var falg = 1; <br>function colortext() <br>{ <br> //获取文字的大小 <br> document.getElementById("text").style.color = getcolor(); <br> document.getElementById("text").style.fontSize = getSize(); <br> } <br>//设置文字颜色 <br>function getcolor() <br>{ <br> var mycolor = "#"; <br> var color ="123456789abcdef"; <br> var colorcode = color.split(""); <br> for(var i=0;i<6;i ) <BR> { <BR> mycolor =colorcode[Math.floor(15*Math.random())]; <BR> } <BR> return mycolor; <BR>} <BR>//返回字体大小 <BR>function getSize() <BR>{ <BR> if(falg == 1) <BR> { <BR> size = size 1; <BR> if(size == 60) <BR> falg = 0; <BR> return size; <BR> } <BR> if(falg == 0) <BR> { <BR> size = size-1; <BR> if(size == 20) <BR> falg = 1; <BR> return size; <BR> } <BR>} <BR>setInterval("colortext()",200); <BR></script> <br></body> <br> </div>