|
霓虹灯广告字
以下是代码片段:
<SCRIPT language=JavaScript> <!-- Begin var speed = 20; var cycledelay = 1000; var maxsize = 48;
var x = 0; var y = 0; var themessage, size; var esize = "";
function initArray() { this.length = initArray.arguments.length; for (var i = 0; i < this.length; i++) { this[i] = initArray.arguments[i]; } } var themessage2 = new initArray( "网站通建站专家网", "欢迎您的光临", "企业建站", "能成为您创业的好帮手" ); if(navigator.appName == "Netscape") document.write('<layer id="wds"></layer><br>'); if (navigator.appVersion.indexOf("MSIE") != -1) document.write('<span id="wds"></span><br>'); function upwords(){ themessage = themessage2[y]; if (x < maxsize) { x++; setTimeout("upwords()",speed); } else setTimeout("downwords()",cycledelay);
if(navigator.appName == "Netscape") { size = "<font point-size='"+x+"pt'>"; document.wds.document.write(size+"<center>"+themessage+"</center>"+esize); document.wds.document.close(); } if (navigator.appVersion.indexOf("MSIE") != -1){ wds.innerHTML = "<center>"+themessage+"</center>"; wds.style.fontSize=x+'px' } } function downwords(){ if (x > 1) { x--; setTimeout("downwords()",speed); } else { setTimeout("upwords()",cycledelay); y++; if (y > themessage2.length - 1) y = 0; } if(navigator.appName == "Netscape") { size = "<font point-size='"+x+"pt'>"; document.wds.document.write(size+"<center>"+themessage+"</center>"+esize); document.wds.document.close(); } if (navigator.appVersion.indexOf("MSIE") != -1){ wds.innerHTML = "<center>"+themessage+"</center>"; wds.style.fontSize=x+'px' } } setTimeout("upwords()",speed); // End --> </SCRIPT>
代码说明:
1. var maxsize = 48; 这句代码定义了文字变化为最大时的字体大小,单位是像素,可以根据我们的实际需要修改大小 2. var themessage2 = new initArray( "网站通建站专家网", "欢迎您的光临", "希望建站", "能成为您创业的好帮手" );
这段代码定义了效果中要显示的文字,每次显示一行的内容,共四行,可以根据我们的实际需要进行修改.
检测代码效果 请进
|