首页 > 新闻系统 > 编程天地 > 文章正文

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>
9 7 3 1 2 4 8 :

相关文章:

    无相关新闻
    无相关新闻

精彩推荐
焦点大图推荐
本类热门文章

论坛美图

广告联系 | 版权说明 | 意见建议 | 加入收藏 | 军网站群 [ 军软件园 - 军软件商城 - 军软件园论坛 ]

电信与信息服务业务经营许可证:京ICP证050203