首页 > 解决方案 > 滚动时从数据库中加载更多数据在 IE 11 中不起作用

问题描述

我尝试在滚动到底部时加载更多数据。在 Edge、Chrome、Firefox 中一切正常,但在 IE 11 中却不行。那里没有任何反应

这是我的代码:

$(window).scroll(function() {
    if ($(document).height() <= $(this).scrollTop() + $(this).height()) {
        if (timer) {
            window.clearTimeout(timer);
        }
        timer = window.setTimeout(function() {
            // Magic goes here
        }, 400);
    }
});

元标记设置为

<meta http-equiv="X-UA-Compatible" content="IE=edge">

很多谢谢

编辑

如果我在 IE 上打开调试模式,一切正常。没有错误

标签: javascriptjqueryinternet-explorer-11

解决方案


刚刚在 IE11 上测试了您的代码示例,并且运行良好。这是我在浏览器中运行的测试代码:

var timer;

$(window).scroll(function(){        
    if ($(document).height() <= $(this).scrollTop() + $(this).height()) {
        if(timer) {
            window.clearTimeout(timer);
        }
        timer = window.setTimeout(function() {
            alert('bottom of page');
         });
     }
});

在 IE11 上的控制台中是否有任何错误?分享更多有问题的代码会有所帮助,因为您给出的示例没有内在的理由不能在 IE11 上运行。


推荐阅读