0

I have a jquery animate that will scroll to the bottom of the page.

I use this scroll animate code in my AJAX code.

the scroll animate affect works fine in Firefox but it doesn't work Google chrome for some reason!

could someone please advise on this?

this is my code:

$('html, body').animate({ scrollTop: $(document).height() }, 'slow');

and this is how I use it my AJAX:

<script type="text/javascript">
$(document).ready(function () {

    function load() {
        $.ajax({ 
            type: "GET",
            url: "MYFILE.php",
            dataType: "html", //expect html to be returned                
            success: function (response) {
                $("#messageme").html(response);
                $('html, body').animate({ scrollTop: $(document).height() }, 'slow');


                setTimeout(load, 800);


            }

        });
    }

    load();
});
</script>

any help would be appreciated.

user3806613
  • 510
  • 2
  • 11
  • 25

2 Answers2

1

This question already seems to be answered. Please refer to this post for the answer.

Simply use : $(document).scrollTop();

Community
  • 1
  • 1
speakerBox
  • 11
  • 3
  • I dont know why this answer's got upvote! using $(document).scrollTop(); will push the page to the top and not scroll to the bottom! – user3806613 Oct 08 '14 at 12:37
0

Chrome Fix is this:

            $('html, body').animate({ 
   scrollTop: $(document).height()-$(window).height()}, 
   1000, 
   "swing"
);
user3806613
  • 510
  • 2
  • 11
  • 25