分享

文字彩幻打字机效果

 fe非 2011-05-20

文字彩幻打字机效果代码如下:

 

<Script language="JavaScript">

var someText = "网页。博客。代码大合集。http://www.u8.blog.163.com/"; // the text
var aChar;
var aSentence;
var i=0; // a counter

var colors = new Array("FF0000","FFFF66","FF3399","00FFFF","FF9900","00FF00"); // the colors
var aColor; // the chosen color

function loadText()
{
// randomly choose color
aColor = colors[Math.floor(Math.random()*colors.length)];

aChar = someText.charAt(i);
if (i == 0)
aSentence = aChar;
else
aSentence += aChar;

// 50 iterations max.
if (i < 50) i++;

// For IE
if (document.all)
{
textDiv.innerHTML= "<font color='#"+aColor+"' face='Tahoma' size='5'><i>"+aSentence+"</i>";
setTimeout("loadText()",100);
}

// For Netscape Navigator 4
else if (document.layers)
{
document.textDiv.document.write("<font color='#"+aColor+"' face='Tahoma' size='5'><i>"+aSentence+"</i>");
document.textDiv.document.close();
setTimeout("loadText()",100);
}

// For other
else if (document.getElementById)
{
document.getElementById("textDiv").innerHTML = "<font color='#"+aColor+"' face='Tahoma'size='5'><i>"+aSentence+"</i>";
setTimeout("loadText()",100);
}
}
</SCRIPT>
</HEAD>
<body bgcolor="#000000" text="#ffffff" onLoad="loadText()">

<div id="textDiv"></div>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约