$(window).scroll不适用于IE11 [英] $(window).scroll does not work with IE11

查看:552
本文介绍了$(window).scroll不适用于IE11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经制作了一个无限滚动功能来获取Ajax数据,它可以正常运行,但不能在iE 11中运行

Hi i've made an endless scroll function to fetch ajax data, its working perfecly but not in iE 11

部分代码:

$(window).load(function(){
  $(window).scroll(function(){
         if($(window).scrollTop() >= ($(document).height() - $(window).height())){
          limitFeeds += 30;
          getFeeds("noloop",limitFeeds);
         }
  });
});

有什么问题吗?

谢谢

推荐答案

jQuery的用于处理滚动事件的抽象方法可以在Internet Explorer中正常工作.但是请注意,jQuery 2.x适用于IE9 +,而jQuery 1.x适用于IE8及以下版本.确保您要使用的浏览器使用属性版本.

jQuery's abstract method for handling scroll events works as expected in Internet Explorer. Note however that jQuery 2.x is intended for IE9+, while jQuery 1.x is reserved for IE8 and below. Be sure you are using the property version for the browsers you intend to target.

以下内容(对 debounce 使用lodash)呈现了您在IE11中期望的结果:

The following (using lodash for debounce) renders the results you're expecting in IE11:

(function () {

    "use strict";

    var debounced = _.debounce(function () {
        if ($win.scrollTop() >= $doc.height() - $win.height()) {
            // AJAX here
        }
    }, 250);

    var $doc = $(document), 
        $win = $(window).on("scroll", debounced);

}());

您可以在此处在线进行测试: http://jsfiddle.net/jonathansampson/74cTx/

You can test this online here: http://jsfiddle.net/jonathansampson/74cTx/

如果您仍然遇到问题,我将使用您的getFeeds方法来确定它是否按预期运行.如果您在此处共享实施方式,我们将很乐意为您提供帮助,以进一步解决问题.

If you continue to have issues, I would look to your getFeeds method to determine whether it is working as you expect it to or not. If you share the implementation here, we'd be happy to assist you in resolving the issue further.

这篇关于$(window).scroll不适用于IE11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆