0

As the following works on all browsers except Internet Explorer 7, which I need it to work on mainly,

$( window ).scroll(function() { alert("Hello"); })

http://jsfiddle.net/zrEFU/

Is there any way that this could be implemented myself? Not too sure on how to go about it. Would anyone be able to point me in the right direction?

AkshaiShah
  • 5,739
  • 11
  • 37
  • 45
  • Some references from here and the rest of internet, as I also want to find a solution to this; http://stackoverflow.com/questions/13881008/jquery-window-scroll-and-internet-explorer-8-9 http://stackoverflow.com/questions/8725536/jquery-scroll-doesnt-work-in-ie-7-and-ie-8 http://forum.jquery.com/topic/make-window-scroll-work-in-ie – Ekin May 18 '14 at 13:50

2 Answers2

1

Make sure to use jQuery 1.x since that version will keep x-browser support. If you use jQuery 2.x you will loose x-browser support.

$(window).scroll(function(){});

DEMO jQuery 1.11.0 => IE6,7,8 support YES

DEMO jQuery 2.x(edge) => IE6,7,8 support NO

In return, jQuery 2.x is smaller, faster, and can be used in JavaScript environments where the code needed for old-IE compatibility often causes problems of its own.

Tim Vermaelen
  • 6,869
  • 1
  • 25
  • 39
-1

I usually prefer to use a timer instead of scroll events. I haven't tried on IE7 though.

I would do something like so:

var topy = 0;
var interval = setInterval(function(){
    if ($(window).scrollTop() !== topy) {
        topy = $(window).scrollTop();

        // whatever you need to do...

    }
},200);
Maurice Perry
  • 32,610
  • 9
  • 70
  • 97