本文实例讲述了JavaScript实现标题栏文字轮播效果代码。分享给大家供大家参考,具体如下:
这里演示的JS文字轮播,显示在标题栏区域,以前个人主页时候经常见到的效果,不过现在都规范了,标题栏一般都不加入这种效果了。但是可以学习一下JS制作实现一些文字特效,运行效果后请查看标题栏。
运行效果截图如下:
在线演示地址如下:
http://demo.VeVB.COm/js/2015/js-title-loop-show-style-demo/
具体代码如下:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>文字循环出现</title></head><body><SCRIPT LANGUAGE="JavaScript">var message = new Array();message[0] = "欢迎光临武林网";message[1] = "这里有javascript";message[2] = "网页特效";message[3] = "图片和背景特效等";message[4] = "非常多的资源";message[5] = "你一定会有所收获的"; message[6] = "欢迎你再次光临";message[7] = "";var reps = 2;var speed = 60;var p = message.length;var T = "";var C = 0;var mC = 0;var s = 0;var sT = null;if (reps < 1) reps = 1;function doTheThing() {T = message[mC];A();}function A() {s++;if (s > 9) { s = 1;}if (s == 1) { document.title = '|||★★★★★=====|||----- ['+T+' -----'; }if (s == 2) { document.title = '|||=★★★★★====|||----- ['+T+' -----'; }if (s == 3) { document.title = '|||==★★★★★===|||----- ['+T+' -----'; }if (s == 4) { document.title = '|||===★★★★★==|||----- ['+T+' -----'; }if (s == 5) { document.title = '|||====★★★★★=|||----- ['+T+' -----'; }if (s == 6) { document.title = '|||=====★★★★★|||----- ['+T+' -----'; }if (s == 7) { document.title = '|||====★★★★★=|||----- ['+T+' -----'; }if (s == 8) { document.title = '|||===★★★★★==|||----- ['+T+' -----'; }if (s == 9) { document.title = '|||=★★★★★===|||----- ['+T+' -----'; }if (C < (8 * reps)) {sT = setTimeout("A()", speed);C++;}else {C = 0;s = 0;mC++;if(mC > p - 1) mC = 0;sT = null;doTheThing(); }}doTheThing();</script></body></html>
希望本文所述对大家JavaScript程序设计有所帮助。
新闻热点
疑难解答