疯狂

STANDING ON THE SHOULDERS OF GIANTS
posts - 481, comments - 486, trackbacks - 0, articles - 1
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

html标题滚动例子

Posted on 2010-11-22 09:37 疯狂 阅读(3615) 评论(3)  编辑  收藏 所属分类: java web
首先是:
titlescroll.js文件
function titleScroll(title_string,timestoloop){
    
      var index_count 
= 0;
      var cmon;
    var kill_length 
= 0;
    var times 
= 0;
       var title_string 
= title_string;
       var title_length 
= title_string.length;
       var timestoloop 
= timestoloop;
       
this.scrollTheTitle = function(){
           
              var doc_title 
= title_string.substring(index_count,title_length);
          
           document.title 
= doc_title;    
           index_count
++;
           }
;
       
       
this.loopTheScroll = function(){
            var my 
= this;
              my.scrollTheTitle();
                
if(kill_length >= title_length)
                 
{
                         
if(times+1<timestoloop){
                             times
++;
                             kill_length
=0;
                             index_count
=0;
                             cmon 
= setTimeout(function(){my.loopTheScroll();},0)
                         }
else{
                        clearTimeout(cmon);
                      }

                 }
else{
                
                kill_length
++;
            
//    alert(kill_length);
                
//alert(times);
                cmon = setTimeout(function(){my.loopTheScroll();},300);
            }

       }

    
}

调用:
var sc = new titleScroll("这是要滚动的内容",2);//参数1: 要滚动的内容,参数2:滚动的次数
c.loopTheScroll();
例子下载
/Files/freeman1984/sc.rar

评论

# re: html标题滚动例子  回复  更多评论   

2010-11-24 16:05 by Beautyleg
下来看看 呵呵

# re: html标题滚动例子  回复  更多评论   

2012-11-28 17:13 by 咸宁装修网
re: html标题滚动例子

# re: html标题滚动例子  回复  更多评论   

2013-03-31 13:45 by 坑货
不错谢谢了帮我解决了一个大难题

只有注册用户登录后才能发表评论。


网站导航: