Home >Web Front-end >JS Tutorial >JavaScript implements title bar text carousel effect code_javascript skills

JavaScript implements title bar text carousel effect code_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:35:292638browse

The example in this article describes the JavaScript code to implement the title bar text carousel effect. Share it with everyone for your reference, the details are as follows:

The JS text carousel demonstrated here is displayed in the title bar area. It was an effect often seen on personal homepages in the past, but now it is standardized and this effect is generally not added to the title bar. But you can learn JS to create some text effects. Please check the title bar after running the effect.

The screenshot of the running effect is as follows:

The online demo address is as follows:

http://demo.jb51.net/js/2015/js-title-loop-show-style-demo/

The specific code is as follows:

<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>

I hope this article will be helpful to everyone in JavaScript programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn