Tom Hanson
Tom Hanson

Reputation: 935

IE10 JQuery.scrollTop() not working

I am trying to register the scrolling of a user. I have it working in ALL browser except that piece of "lovely software" Internet Explorer.

$(window).scroll(function()
    {
        var windowY = $(window).height();
        var scrolledY = $(window).scrollTop();
        if(scrolledY < 500)
        {
            $('#showcase3').css('display', 'none');
            $('#showcase1').css('display', 'block');
            $('#showcase2').css('display', 'none');
        }
        if(scrolledY > 500 && scrolledY < 1500)
        {
            $('#showcase3').css('display', 'none');
            $('#showcase1').css('display', 'none');
            $('#showcase2').css('display', 'block');
        }
        if(scrolledY > 1500)
        {
            $('#showcase1').css('display', 'none');
            $('#showcase2').css('display', 'none');
            $('#showcase3').css('display', 'block');
        }
    });
    $(document).ready(function(){

     // Scroll page to the bottom
        $('a#Tom').click(function()
        {
            $('body').animate({scrollTop: 1000}, 500);
            return false;
        });
        $('a#Bel').click(function()
        {
            $('body').animate({scrollTop: 2000}, 500);
            return false;
        });
        $('a#Portfolio').click(function()
        {
            $('body').animate({scrollTop: 0}, 500);
            return false;
        });
        $('a#service').click(function()
        {
            $('body').animate({scrollTop: 1500}, 500);
            return false;
        });
        $('a#contactlink').click(function()
        {
            $('body').animate({scrollTop: $(document).height()}, 500);
            return false;
        });
        $('a#OurMission').click(function()
        {
            $('body').animate({scrollTop: 500}, 500);
            return false;
        });
        $('body').animate({scrollTop: 500}, 0);
    })  

The document.getElementById('OurMission').innerHTML = scrolledY; was my test to see if that was the error.

How do I get Jquery to work in IE10

Upvotes: 1

Views: 1742

Answers (1)

fearis
fearis

Reputation: 499

Heh, I foaund solution 4 months ago for that, I forgotten, I've found this question and it will reminde me solution ;)

Use :

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

$('html, body') to any code which have body.

Upvotes: 1

Related Questions