效果演示
http://www.home.sunbo.com/xfile.php?xname=686QF01&fname=/texiao_3/%B6%AF%CC%AC%CE%C4%D7%D6.html代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>动态文字 - www.home.sunbo.com</title>
<style>
<!--
div { font-family: Tahoma }
-->
</style>
</head>
<body
onload="startmotor(0)">
<script language="JavaScript1.2">
/*
Shock Wave Text script- By ejl(AT)worldmailer.com
Submitted to and featured on Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/
var size = 25;
var speed_between_messages=1500 //in miliseconds
var tekst = new Array()
{
tekst[0] = "Shock Wave text @ Dynamicdrive.com";
tekst[1] = "Here you can type anything you want";
tekst[2] = "You can change the size";
tekst[3] = "And you can change the speed";
}
var klaar = 0;
var s = 0;
var veran =0;
var tel = 0;
function bereken(i,Lengte)
{
return (size*Math.abs( Math.sin(i/(Lengte/3.14))) );
}
function motor(p)
{
var output = "";
for(w = 0;w < tekst[s].length - klaar+1; w++)
{
q = bereken(w/2 + p,16);
if (q > size - 0.5)
{klaar++;}
if (q < 5)
{tel++;
if (tel > 1)
{
tel = 0;
if (veran == 1)
{
veran = 0;
s++;
if ( s == tekst.length)
{s = 0;}
p = 0;
if (window.loop)
{clearInterval(loop)}
loop = motor();
}
}
}
output += "<font style='font-size: "+ q +"pt'>" +tekst[s].substring(w,w+1)+ "</font>";
}
for(k=w;k<klaar+w;k++)
{
output += "<font style='font-size: " + size + "pt'>" +tekst[s].substring(k,k+1)+ "</font>";
}
idee.innerHTML = output;
}
function startmotor(p){
if (!document.all)
return
var loop = motor(p);
if (window.time)
{clearInterval(time)}
if (klaar == tekst[s].length)
{
klaar = 0;
veran = 1;
tel = 0;
var time = setTimeout("startmotor(" +(p+1) + ")", speed_between_messages);
}else
{
var time =setTimeout("startmotor(" +(p+1) + ")", 50);
}
}
</script>
<div ID="idee">
</div>
</body>
</html>