文字自动循环滚动js函数
来源:互联网 发布:python sift 编辑:程序博客网 时间:2024/05/04 00:53
<script language='javascript'><!--/********************************//* 文字自动循环滚动 *//* IE6 FF1.0.4 *//* 不支持xhtml声明的文档 *//********************************///*********不要修改这部分***************//scrollBodyId: String 内部滚动div的id//scrollBoxId: String 外面限制div的id//showHeight: Int 限制显示高度//showWidth: Int 限制显示宽度//lineHeight: Int 每行的高度//stopTime: Int 间隔停止的时间(毫秒)//speed: Int 滚动速度(毫秒,越小越快)var ScrollObj = function(scrollBodyId,scrollBoxId,showHeight,showWidth,lineHeight,stopTime,speed) { this.obj = document.getElementById(scrollBodyId); this.box = document.getElementById(scrollBoxId); this.style = this.obj.style; this.defaultHeight = this.obj.offsetHeight; this.obj.innerHTML += this.obj.innerHTML; this.obj.style.position = "relative"; this.box.style.height = showHeight; this.box.style.width = showWidth; this.box.style.overflow = "hidden"; this.scrollUp = doScrollUp; this.stopScroll = false; this.curLineHeight = 0; this.lineHeight = lineHeight; this.curStopTime = 0; this.stopTime = stopTime; this.speed = speed; this.style.top = lineHeight; this.object = scrollBodyId + "Object"; eval(this.object + "=this"); setInterval(this.object+".scrollUp()",speed); this.obj.onmouseover=new Function(this.object+".stopScroll=true"); this.obj.onmouseout=new Function(this.object+".stopScroll=false");}function doScrollUp() { if( this.stopScroll == true ) return; this.curLineHeight += 1; if( this.curLineHeight >= this.lineHeight ) { this.curStopTime += 1; if( this.curStopTime >= this.stopTime ) { this.curLineHeight = 0; this.curStopTime = 0; } } else { this.style.top = parseInt(this.style.top) - 1; if( -parseInt(this.style.top) >= this.defaultHeight ) { this.style.top = 0; } }}//***************这以上不要修改******************//--></script> 调用方法:<div id="scroollBox" style="border:0px ; "><div id="scroollBody">阿斯科利的积分卡士大夫</div></div><script language="javascript" type="text/javascript"><!--//var sample = new ScrollObj(String 内部滚动div的id, String 外面限制div的id, Int 限制显示高度, Int 限制显示宽度, Int 每行的高度, Int 间隔停止的时间(毫秒), Int 滚动速度(毫秒,越小越快));var sample = new ScrollObj("scroollBody", "scroollBox", 110, 560, 111, 50, 10);// --></script> 左右滚动 js:var speed3=25//速度数值越大速度越慢demo2.innerHTML = demo1.innerHTMLfunction Marquee(){ if(demo2.offsetWidth-demo.scrollLeft<=0) demo.scrollLeft-=demo1.offsetWidth else{ demo.scrollLeft++ }}var MyMar = setInterval(Marquee, speed3)demo.onmouseover=function() {clearInterval(MyMar)}demo.onmouseout = function() { MyMar = setInterval(Marquee, speed3) }调用 方法: <DIV id=demo style="OVERFLOW: hidden; WIDTH: 100%; COLOR: #ffffff"> <TABLE cellSpacing=0 cellPadding=0 align=left border=0 cellspace="0"> <TBODY> <TR> <TD id=demo1 vAlign=top><table width="1710" height="116" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="171" background="images/pic_bg.jpg"><div align="center">1</div></td> <td width="171" background="images/pic_bg.jpg"><div align="center"> <p>2</p> </div></td> <td width="171" background="images/pic_bg.jpg"><div align="center">3</div></td> <td width="171" background="images/pic_bg.jpg"><div align="center">4</div></td> <td width="171" background="images/pic_bg.jpg"><div align="center">5</div></td> <td width="171" background="images/pic_bg.jpg"><div align="center">6</div></td> <td width="171" background="images/pic_bg.jpg"><div align="center">7</div></td> <td width="171" background="images/pic_bg.jpg"><div align="center">8</div></td> <td width="171" background="images/pic_bg.jpg"><div align="center">9</div></td> <td width="171" background="images/pic_bg.jpg"><div align="center">10</div></td> </tr> </table></TD> <TD id=demo2 vAlign=top> </TD></TR></TBODY></TABLE></DIV>
0 0
- 文字自动循环滚动 的js 函数
- 文字自动循环滚动js函数
- js文字循环滚动
- js文字循环滚动效果
- JS实现div内部的文字或图片自动循环滚动
- JS实现div内部的文字或图片自动循环滚动
- js图片文字上下自动滚动
- 文字循环向上滚动
- 文字标签循环滚动
- 文字左右循环滚动
- 文字循环向上滚动
- 文字定时滚动js
- 文字滚动JS
- js 滚动文字
- 文字滚动JS
- js文字滚动
- js文字滚动
- js不间断文字滚动
- 推荐一下Thrift的专栏
- zmq poll实例
- 关于cocos2d-x3.0和2.0之间的区别
- 内核配置zImage
- 移动互联网时代的9大赚钱机会
- 文字自动循环滚动js函数
- perl last next redo区别
- 非线性Z和反Z曲线
- TextView.setTextColor(int); 括号里那个颜色int值的理解
- IOS7.0 Xcode5 AutoLayout 备忘录
- 前端工程打开速度优化的循序渐进总结
- 显示数学公式
- Redhat Linux多路径multi-path详解
- [3] spring mvc学习笔记