资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
js 上下文字滚动效果
js实现的文字向上滚动效果,适合文字公告等。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>test</title> <style type="text/css"> #textHeight{line-height:25px; height:25px; overflow:hidden; width:150px; font-size:12px; border:solid 1px #666;} </style> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20language%3D%22javascript%22%20type%3D%22text%2Fjavascript%22%3E%20%0D%0Afunction%20ScrollText(content)%7B%20%0D%0Athis.Delay%3D10%3B%20%0D%0Athis.Amount%3D1%3B%20%0D%0Athis.Direction%3D%22up%22%3B%20%0D%0Athis.Timeout%3D1000%3B%20%0D%0Athis.ScrollContent%3Dthis.gid(content)%3B%20%0D%0Athis.ScrollContent.innerHTML%20%2B%3D%20this.ScrollContent.innerHTML%3B%20%0D%0Athis.ScrollContent.onmouseover%20%3D%20this.GetFunction(this%2C%22Stop%22)%3B%20%0D%0Athis.ScrollContent.onmouseout%20%3D%20this.GetFunction(this%2C%22Start%22)%3B%20%0D%0A%7D%20%0D%0A%0D%0AScrollText.prototype.gid%3Dfunction(element)%7B%20%0D%0Areturn%20document.getElementById(element)%3B%20%0D%0A%7D%20%0D%0AScrollText.prototype.Stop%3Dfunction()%7B%20%0D%0AclearTimeout(this.AutoScrollTimer)%3B%20%0D%0AclearTimeout(this.ScrollTimer)%3B%20%0D%0A%7D%20%0D%0AScrollText.prototype.Start%3Dfunction()%7B%20%0D%0AclearTimeout(this.AutoScrollTimer)%3B%20%0D%0Athis.AutoScrollTimer%3DsetTimeout(this.GetFunction(this%2C%22AutoScroll%22)%2Cthis.Timeout)%3B%20%0D%0A%7D%20%0D%0A%0D%0AScrollText.prototype.AutoScroll%3Dfunction()%7B%20%0D%0Aif(this.Direction%3D%3D%22up%22)%7B%20%0D%0Aif(parseInt(this.ScrollContent.scrollTop)%3E%3DparseInt(this.ScrollContent.scrollHeight)%2F2)%7B%20%0D%0Athis.ScrollContent.scrollTop%3D0%3B%20%0D%0AclearTimeout(this.AutoScrollTimer)%3B%20%0D%0Athis.AutoScrollTimer%20%3D%20setTimeout(this.GetFunction(this%2C%22AutoScroll%22)%2C%20this.Timeout)%3B%20%0D%0Areturn%3B%20%0D%0A%7D%20%0D%0Athis.ScrollContent.scrollTop%20%2B%3D%20this.Amount%3B%20%0D%0A%7Delse%20%0D%0A%7B%20%0D%0Aif(parseInt(this.ScrollContent.scrollTop)%20%3C%3D%200)%20%0D%0A%7B%20%0D%0Athis.ScrollContent.scrollTop%20%3D%20parseInt(this.ScrollContent.scrollHeight)%20%2F%202%3B%20%0D%0A%7D%20%0D%0Athis.ScrollContent.scrollTop%20-%3D%20this.Amount%3B%20%0D%0A%7D%20%0D%0Aif(parseInt(this.ScrollContent.scrollTop)%20%25%20this.LineHeight%20!%3D%200)%20%0D%0A%7B%20%0D%0Athis.ScrollTimer%20%3D%20setTimeout(this.GetFunction(this%2C%22AutoScroll%22)%2C%20this.Delay)%3B%20%0D%0A%7D%20%0D%0Aelse%20%0D%0A%7B%20%0D%0Athis.AutoScrollTimer%20%3D%20setTimeout(this.GetFunction(this%2C%22AutoScroll%22)%2C%20this.Timeout)%3B%20%0D%0A%7D%20%0D%0A%7D%20%0D%0A%0D%0AScrollText.prototype.GetFunction%3Dfunction(variable%2Cmethod)%7B%20%0D%0Areturn%20function()%20%0D%0A%7B%20%0D%0Avariable%5Bmethod%5D()%3B%20%0D%0A%7D%20%0D%0A%7D%20%0D%0A%3C%2Fscript%3E"> </head> <body> <div id="textHeight" title="xx"> <a href="#" _ewebeditor_ta_href="%23">博客园</a> <span> | </span> <a href="#" _ewebeditor_ta_href="%23">管理资源吧</a> <span> | </span> <a href="#" _ewebeditor_ta_href="%23">csdn</a> <span> | </span> <a href="#" _ewebeditor_ta_href="%23">蓝色理想</a> <span> | </span> <a href="#" _ewebeditor_ta_href="%23">51js</a> <span> | </span> </div> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%3E%20%0D%0Avar%20scrollup%20%3D%20new%20ScrollText(%22textHeight%22)%3B%20%0D%0Ascrollup.Start()%3B%20%0D%0A%3C%2Fscript%3E"> </body> </html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程