聊天室里的滚动条自动向下滚动

 今天接到通知说要搞个聊天室,这个东西网上多的不得了,随便一搜到处都是,但是要一个真正适合自己的恐怕还要自己动手了。在用JavaScript调节滚动条自动向下滚动的时候,发现了几个方法,特此记在这里:

 

首先是doScrooll方法,可以指定滚动的方向。但是不能一下子滚动到最极端。

 

object

.doScroll(
 [
sScrollAction
]
)

sScrollAction
Optional.
A String  that specifies how the object scrolls, using one of the following values.
scrollbarDown
Default. Down scroll arrow is at the specified location.
scrollbarHThumb
Horizontal scroll thumb or box is at the specified location.
scrollbarLeft
Left scroll arrow is at the specified location.
scrollbarPageDown
Page-down scroll bar shaft is at the specified location.
scrollbarPageLeft
Page-left scroll bar shaft is at the specified location.
scrollbarPageRight
Page-right scroll bar shaft is at the specified location.
scrollbarPageUp
Page-up scroll bar shaft is at the specified location.
scrollbarRight
Right scroll arrow is at the specified location.
scrollbarUp
Up scroll arrow is at the specified location.
scrollbarVThumb
Vertical scroll thumb or box is at the specified location.

如果想一下子滚到最下面可以用下面的代码(IE和Firefox都可以用):
f(divContent.scrollHeight>divContent.offsetHeight)
divContent.scrollTop=divContent.scrollHeight-divContent.offsetHeight;
注:divContent是一个带滚动条的div。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值