1. 程式人生 > >CSS+JS控制字型閃爍

CSS+JS控制字型閃爍

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文件</title>
<script type="text/javascript">

var colors = new Array("CC3300","669900","FF6699");
var colors1 = new Array("CC0066","CCCC00","CC3300");
var colors2 = new Array("FF9933","CC0033","FF6633");
var colors3 = new Array("00CCCC","FF9900","CC3300");

var aColor; 
var aColor1;
var aColor2;
var aColor3;
function loadText()
{

 aColor = colors[Math.floor(Math.random()*colors.length)];
 aColor1 = colors1[Math.floor(Math.random()*colors.length)];
 aColor2 = colors2[Math.floor(Math.random()*colors.length)];
 aColor3 = colors3[Math.floor(Math.random()*colors.length)];

document.getElementById("textDiv").style.color="#"+aColor;
document.getElementById("textDiv1").style.color="#"+aColor1;
document.getElementById("textDiv2").style.color="#"+aColor2;
document.getElementById("textDiv3").style.color="#"+aColor3;
setTimeout("loadText()",500);

}
</script>
</head>

<body onload="loadText()">

<span id="textDiv"><i>手</i></span>
<span id="textDiv1"><i>機</i></span>
<span id="textDiv2"><i>電</i></span>
<span id="textDiv3"><i>視</i></span>

</body>
</html>