javascrpt实现间隔性滚动的效果2008-04-09 10:20:11 来源:中国自学编程网 作者:未知 点击:
![]() ScrollText.prototype.Scroll = function(direction)
{ if(direction=="up") { this.ScrollContent.scrollTop--; } else { this.ScrollContent.scrollTop++; } if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) { this.ScrollContent.scrollTop = 0; } if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0) { this.ScrollTimer = setTimeout(this.GetFunction(this,"Scroll",direction), this.Speed); } } ScrollText.prototype.GetFunction = function(variable,method,param)
{ return function() { variable[method](param); } } Demo.Htm
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <script language="javascript" type="text/javascript" src="ScrollText.js"></script> </head> <body> <div id="pre" style="width:20px;height:20px;float:left;text-align:center;background-color:#EEEEEE;border:solid 1px #888888;">↑</div> <div id="content" style="height:20px;line-height:20px;overflow:hidden;float:left;width:120px;border:solid 1px #0000FF;"> hello1........<br> hello2........<br> hello3........<br> hello4........<br> hello5........<br> hello6........<br> hello7........<br> hello8........<br> </div> <div id="next" style="width:20px;height:20px;float:left;text-align:center;background-color:#EEEEEE;border:solid 1px #888888;">↓</div> <script language="javascript" type="text/javascript"> var scroll = new ScrollText("content","pre","next",true); </script> </body> </html> 相关文章:
|