jQuery Scroll doesn't work in IE 7 and IE 8

2019-03-04 14:06发布

Here is an example of what I use:

jQuery(document).ready(function() {

    console.log('scroll');

    jQuery(window).scroll(function () {
        console.log('scrolling 1');
    });

    jQuery(document).scroll(function () {
        console.log('scrolling 2');
    });
});

This will only return "scroll in IE 7 and IE 8.
And in Chrome, Firefox and IE 9 it will return everything one time and "scrolling 2" whenever I'm scrolling.

I am also locked to jQuery 1.3

Does anyone have any idea how to get this working in IE 7 and IE 8?


Edit:
I have now found out that the reason of this seems to relate to a jQuery Lightbox Plugin.

2条回答
啃猪蹄的小仙女
2楼-- · 2019-03-04 14:40

The issue was on row 817 in jquery.lightbox.js

$(window).unbind().resize(function ()

This will unbind everything connected to $(window) and not only resize.
So the solution is:

$(window).unbind('resize').resize(function ()
查看更多
闹够了就滚
3楼-- · 2019-03-04 14:41

Check out the ScrollTo plug-in.

http://flesler.blogspot.com/2007/10/jqueryscrollto.html

Their demo page uses jQuery 1.3.2 -

http://demos.flesler.com/jquery/scrollTo/

Also note:

Doesn't scroll on IE. Sometimes, you need to set a position (relative or absolute) to the container and give it fixed dimensions, in order to hide the overflow. If this doesn't work, try giving the container fixed dimensions (height & width).

UPDATED Using jQuery 1.11.1, using jquery.scrollTo release 1.4.13 with the following:

$( '#parent' ).scrollTo( $( '#target' ), 800 );

This works on IE 7.0.5730.11.

查看更多
登录 后发表回答