2

I am working on a delete item function. Its working fine in all browsers but In IE fail to retain it's scroll position. I want to keep the same position after reload of the page

function _removeItem(element) {
    var $target = $(element),
        prodId = $target.data("id");
    something.call('something', {
        productId: prodId
    }).done(function() {
        window.location.reload();
    });
}
ADH - THE TECHIE GUY
  • 4,125
  • 3
  • 31
  • 54
Zeeshan
  • 37
  • 8

1 Answers1

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

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

Credit: https://stackoverflow.com/a/34261611/4666994

Community
  • 1
  • 1
soulivong
  • 139
  • 1
  • 3
  • 10