JS标题闪烁/滚动特效


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS标题闪烁/滚动特效.</title>


<script>
var i=0; 
var time1;
var time2;
var titlex=document.title;
function len(){return titlex.length;}



function _1500kmflash(){
    clearTimeout(time2);
    switch(i){
        case 1:document.title='...';i++;break;
        case 2:document.title=titlex;i++;break;
        default:i=1;break;
    }
    time1=setTimeout("_1500kmflash()",500);
}


function _1500kmScroll(){ 
    clearTimeout(time1);
    document.title=titlex.substring(i,len())+titlex.substring(0,i); 
    i++; 
    if(i>len()){ 
        i=0;
    }
    time2=setTimeout("_1500kmScroll()",500); 
} 


</script>



<button onclick="_1500kmflash()">标题闪烁</button>
<button onclick="_1500kmScroll()">标题滚动</button>


程序运行结果如下,点击这里亲自运行看看