<body bgcolor="#">
<div id="text" style="fontsize:px;">你好這是一段改變文字大小和顏色的javascript代碼</div>
<script type="text/javascript">
var size = ;
var falg = ;
function colortext()
{
//獲取文字的大小
documentgetElementById("text")stylecolor = getcolor();
documentgetElementById("text")stylefontSize = getSize();
}
//設置文字顏色
function getcolor()
{
var mycolor = "#";
var color ="abcdef";
var colorcode = colorsplit("");
for(var i=;i<;i++)
{
mycolor+=colorcode[Mathfloor(*Mathrandom())];
}
return mycolor;
}
//返回字體大小
function getSize()
{
if(falg == )
{
size = size+;
if(size == )
falg = ;
return size;
}
if(falg == )
{
size = size;
if(size == )
falg = ;
return size;
}
}
setInterval("colortext()");
</script>
</body>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19945.html