开发者

Auto-Scroll in FireFox

My application is a Live chat. I have a Div to wrap the messages, each message is a div, so, after a few messages my DOM looks like this :

<div id = "divChatHistory">
   <div id = "msg1> Message number one </div>
   <div id = "msg2> Message number two </div>
   <div id = "msg3> Message number three </div>
   // ...
</div>

Now a need to auto-scrool the divChatHistory for each message, and its realy simple:

function AutoScroll() {
    $('#<%= divChatHistory.ClientID%>').scrollTo开发者_如何学运维p(100000000000);
}

but it works only in Internet Explorer (IE) in FireFox (FF) not happens.

Any Idea ?


Solved.

 function AutoScroll() {
    if (chkRolagem[0].checked) {
        if (jQuery.browser.msie)
            divChatHistory.scrollTop(100000000000);
        else
            divChatHistory.scrollTop(-100000000000);
    }
}

If IE, positive number.

If FF, negative number


You can use the scrollTo plugin. See a demo

Check this one also

Animated Scrolling with jQuery 1.2

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜