实现网页动态标题代码如下
css部分
<div style="display:none" id="w">你好呀,欢迎来到老哥脚本!</div>
<div style="display:none" id="m">嘿嘿,有错误请多指教!</div>
js部分
<script language="javascript">
var index=0;
var inde=0;
var word=document.getElementById("w").innerHTML;
var ha=document.getElementById("m").innerHTML;
function hh(){
var type=setInterval(function(){
document.title=word.substring(0,index++);
if(index==word.length+1){
clearInterval(type);
index=0;
var ty=setInterval(function(){
document.title=ha.substring(0,inde++);
if(inde==ha.length+1){
clearInterval(ty);
inde=0;
hh();
}
},300);
}
},300);
}
setTimeout(hh,2500);
</script>