当前位置:学会吧培训频道电脑知识学习网页制作Javascript教程JavaScript标题新闻的定时翻滚(IE,FF,Opera,Safari,Chrome)» 正文

JavaScript标题新闻的定时翻滚(IE,FF,Opera,Safari,Chrome)

[08-08 00:41:35]   来源:http://www.xuehuiba.com  Javascript教程   阅读:8368
概要:电脑知识下面是主要代码: 程序代码var Scroll=Class.create();Scroll.prototype={//第一个参数定义要滚动的区域,第二个参数定义每次滚动的高度initialize:function(element,height,delay){ this.element=$(element); this.element.innerHTML+=this.element.innerHTML; this.height=height; this.delay=delay*1000; this.maxHeight=this.element.scrollHeight/2; this.counter=0; this.scroll(); this.timer=""; this.element.onmouseover=this.stop.bind(this); this.element.onmouseout=function(){this.timer=setTime
JavaScript标题新闻的定时翻滚(IE,FF,Opera,Safari,Chrome),标签:javascript视频教程,javascript教程下载,http://www.xuehuiba.com
电脑知识

下面是主要代码:

 程序代码
var Scroll=Class.create();
Scroll.prototype={
//第一个参数定义要滚动的区域,第二个参数定义每次滚动的高度
initialize:function(element,height,delay){
  this.element=$(element);
  this.element.innerHTML+=this.element.innerHTML;
  this.height=height;
  this.delay=delay*1000;
  this.maxHeight=this.element.scrollHeight/2;
  this.counter=0;
  this.scroll();
  this.timer="";
  this.element.onmouseover=this.stop.bind(this);
  this.element.onmouseout=function(){this.timer=setTimeout(this.scroll.bind(this),1000);}.bind(this);
},
scroll:function(){
  if(this.element.scrollTop<this.maxHeight){
   this.element.scrollTop++;
   this.counter++;
  }else{
   this.element.scrollTop=0;
   this.counter=0;
  }
 
  if(this.counter<this.height){
   this.timer=setTimeout(this.scroll.bind(this),20);
  }else{
   this.counter=0;
   this.timer=setTimeout(this.scroll.bind(this),this.delay);
  }
},
stop:function(){
  clearTimeout(this.timer);
}
}

电脑知识
Tag:Javascript教程javascript视频教程,javascript教程下载电脑知识学习 - 网页制作 - Javascript教程
Copyright 学会吧 All Right Reserved.
在线学习社区!--学会吧
1 2 3 4 5 6 7 7 8 9 10 11 12 13