標題欄里多段標題文字的替換顯現(xiàn)
發(fā)布時間:2008-12-20 閱讀數(shù): 次 來源:網(wǎng)樂原科技
要完成此效果把如下代碼加入到區(qū)域中
<script LANGUAGE="JavaScript">
var message = new Array();
message[0] = "Welcome To You...";
message[1] = "細溪驛站...";
message[2] = "jojoo@jojoo.net...";
var reps = 1;
var speed = 275;// Set the overall typing speed (larger number = slower action).
var hold = 4 // set the length of time to display the whole phrase before retyping (larger number = longer)
var p = message.length;
var q = 0;
var r = 0;
var C = 0;
var mC = 0;
var s = 0;
var sT = null;
if (reps < 1) {
reps = 1;
}
function setMessage() {
typing = message[mC];
q = typing.length;
r = q + hold;
typeMessage();
}
function typeMessage() {
if (s > r) {
s = 0;
}
if (s > q) {
document.title = '|- '+ typing +' - - -';
}
else {
document.title = '|- '+ typing.substr(0,s)+' - - -';
}
if (C < (r * reps)) {
sT = setTimeout("typeMessage()", speed);
C++;
s++;
}
else {
C = 0;
s = 0;
mC++;
if(mC > p - 1) {mC = 0;}
sT = null;
setMessage();
}
}
setMessage();
</script>