views:

24

answers:

2

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%>').scrollTop(100000000000);
}

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

Any Idea ?

+1  A: 

You can use the scrollTo plugin. See a demo

Check this one also

Animated Scrolling with jQuery 1.2

rahul
i will take a look at the plugin.
Ewerton
+2  A: 

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

Ewerton