2014-02-17 96 views
2

嗨,我已經做了一個無盡的滾動功能來獲取AJAX數據,其perfecly但不工作在IE瀏覽器的代碼11

部分:

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

有什麼問題嗎?

感謝

+2

僅供參考,你不需要包裝滾動處理程序內負載一,你應該debounce onscroll事件。控制檯中有任何錯誤?阿賈克斯請求是否完成? –

+0

我認爲使用目標ID;例如, ; $(「#target」)。scroll(); –

+0

我沒有得到任何的錯誤,並沒有觸發ajax ..我刪除了加載事件 – Anthony

回答

1

jQuery的處理滾動事件抽象方法將按預期在Internet Explorer中。但請注意,jQuery 2.x適用於IE9 +,而jQuery 1.x僅適用於IE8及更低版本。確保您使用的是您打算定位的瀏覽器的屬性版本。

以下(使用lodash爲debounce)使你在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/

,我會看看你的getFeeds方法來確定它是否按照你期望的那樣工作。如果您在這裏分享實施,我們很樂意協助您進一步解決問題。

0

我有這個相同的問題。對我來說,似乎IE11在其他所有卷軸上都是1像素。我解決了它允許一個小的變化:

if ($(window).scrollTop() - ($(document).height() - $(window).height()) <= 5) && ($(window).scrollTop() - ($(document).height() - $(window).height()) >= -5)) 
{ 
    LoadMore(); 
}