文字如同波浪一样在屏幕上波动,用在个人主页上一定增色不少
第一步:
在<head>区添加以下代码:
<SCRIPT language=JavaScript>
/*****************************************************
* Share JavaScript (http://www.ShareJS.com)
* 使用此脚本程序,请保留此声明
* 获取此脚本以及更多的JavaScript程序,请访问 http://www.ShareJS.com
******************************************************/
function nextSize(i,incMethod,textLength)
{
if (incMethod == 1) return (32*Math.abs( Math.sin(i/(textLength/3.14))) );
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
}
function sizeCycle(text,method,dis)
{
output = "";
for (i = 0; i < text.length; i++)
{
size = parseInt(nextSize(i +dis,method,text.length));
output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
}
theDiv.innerHTML = output;
}
function doWave(n)
{
theText = "======欢迎分享JavaScript======";
sizeCycle(theText,1,n);
if (n > theText.length) {n=0}
setTimeout("doWave(" + (n+1) + ")", 50);
}
</SCRIPT>
第二步:
在要出现效果的地方加上以下代码:
<DIV align=center id=theDiv></DIV>
第三步:
在为<body>添加OnLoad事件,如:
<BODY onload=doWave(0)>




