这个函数实现如下

function TimerStart(func,delay)
{
    
var TimerID = window.setInterval(
                                    
function()
                                    {
                                        
if(!func())
                                        {
                                            window.clearInterval(TimerID);
                                        };
                                    },
                                    delay
                                    );
}

调用例子:

//状态栏效果

window.onload=function()
{
    
var i=0;
    
//调用函数
    TimerStart(
            
function()
            {
                window.status 
= i++;//状态栏显示数据
            },
            
50 //速度
            );
}

//跑马灯效果
window.onload =function()
{
    
var str1="   公告:本站属于个人博客,用于收藏本人喜好的原创作品及网络资源,如果您不喜欢千万不要勉强。谢谢合作!~ ";
    
var str2="";
    
var length = str1.length-1;
    
var index = 0;
    TimerStart(
            
function()
            {
                str2 
= str1.substring(index,length)+str1.substring(0,index);
                
                index
++;
                
                
if(index==length-1
                {
                    index
=3;
                }
               
        
                document.title
=str2;
              
                
return true;
            },
            
130
            );
}