我们让网页title标题栏文字滚动起来,通常情况是在<head></head>之间加入一段JavaScript代码,就能实现网页标题栏文字滚动起来。
下面小编给出几个特效实例,供大家学习。在使用时,可以将代码根据自己需要修改。
标题栏文字滚动代码片段一:
<script language="javascript">
<!-- Hide me
var index_count = 0;
var title_string = "IT部落窝,IT技术乐园,我们一起学习电脑知识吧!网址是:www.ittribalwo.com ";
var title_length = title_string.length;
var cmon;
var kill_length = 0;
function loopTheScroll()
{
scrollTheTitle();
if(kill_length > title_length)
{
clearTimeout(cmon);
}
kill_length++;
cmon = setTimeout("loopTheScroll();",100)
}
function scrollTheTitle()
{
var doc_title = title_string.substring((title_length - index_count - 1),title_length);
document.title = doc_title;
index_count++;
}
loopTheScroll();
//-->
</script>
标题栏文字滚动代码片段二:
<script language=javascript >
title_tmp1=document.title
if (title_tmp1.indexOf(">>")!=-1){
title_tmp2=title_tmp1.split(">>");
title_last=" —> "+title_tmp2[1];
title_last=title_last + " —> " + title_tmp2[2];
}else{
if (title_tmp1.indexOf("——")!=-1){
title_tmp2=title_tmp1.split("——");
title_last=" —> "+title_tmp2[1];
if (title_last==" —> "){title_last=" —> "};
if (title_last==" —> "){title_last=" —> "};
}
else { title_last="http://www.ittribalwo.com"}
}
title_new="IT部落窝"+title_last+"" //中间的标题
step=0
function flash_title()
{
step++
if (step==7) {step=1}
if (step==1) {document.title='◆◇◇◇'+title_new+'◇◇◇◆'}
if (step==2) {document.title='◇◆◇◇'+title_new+'◇◇◆◇'}
if (step==3) {document.title='◇◇◆◇'+title_new+'◇◆◇◇'}
if (step==4) {document.title='◇◇◇◆'+title_new+'◆◇◇◇'}
if (step==5) {document.title='◇◇◆◇'+title_new+'◇◆◇◇'}
if (step==6) {document.title='◇◆◇◇'+title_new+'◇◇◆◇'}
setTimeout("flash_title()",180);
}
flash_title()
</script>
标题栏文字滚动代码片段三:
<html>
<head>
<title>IT部落窝,网址:www.ittribalwo.com</title>
<script language=javascript >
var text=document.title
var timerID
function newtext()
{
clearTimeout(timerID)
document.title=text.substring(1,text.length)+text.substring(0,1)
text=document.title.substring(0,text.length)
timerID = setTimeout("newtext()", 100)
}
</script>
</head>
<body onload="newtext()">
</body>
</html>