2016-12-29 55 views
2

我正在處理刪除項目功能。它在所有瀏覽器中都能正常工作,但在IE中無法保留它的滾動位置。我想保持相同位置的頁面重新加載後重新加載頁面後IE不保留它的滾動位置

function _removeItem(element) { 
    var $target = $(element), 
     prodId = $target.data("id"); 
    something.call('something', { 
     productId: prodId 
    }).done(function() { 
     window.location.reload(); 
    }); 
} 
+0

也許在頁面卸載,你寫的腳本來記錄當前的滾動位置,並在頁面加載,你編寫腳本滾動到最後記錄的位置。 – vothaison

+0

哪個版本的IE?異步數據是否也被加載? – charlietfl

+0

IE-11和數據也是異步的 – Zeeshan

回答

1
$(window).scroll(function() { 
    sessionStorage.scrollTop = $(this).scrollTop(); 
}); 

$(document).ready(function() { 
    if (sessionStorage.scrollTop != "undefined") { 
    $(window).scrollTop(sessionStorage.scrollTop); 
    } 
}); 

信用:https://stackoverflow.com/a/34261611/4666994

相關問題