0

I have this code that on scroll adds a hash in the url based on the current section.

$(window).scroll(function(){
  $('.eng-section').each(function(){
          if ( $(this).offset().top < window.pageYOffset + 10 && $(this).offset().top + $(this).height() > window.pageYOffset + 10 ) {
            window.location.hash = $(this).attr('id');
          }
        });
      });
  });

In chrome everything works fine, but in mozilla when the first hash is added in the url, scrolling doesn't seem to work anymore. Any ideas why this is happening?

  • What error you get in your console? – Ankit Kathiriya Jan 07 '16 at 11:52
  • Setting `window.location.hash` makes browser to scroll to specifc element. This behaviour can be handled quite differently depending browser implementation. FF e.g would fire the scroll event still even you are trying to manually scroll the page, blocking the scrolling user ability, not chrome. See [jsFiddle](https://jsfiddle.net/5qagqLvk/) and compare – A. Wolff Jan 07 '16 at 11:58
  • I get no errors in the console, that's the problem – Sophia Mi Jan 07 '16 at 12:26

0 Answers0