Firefox not scrolling to Anchor Links Tags position (Solution)

Go straight to the solution

Issue

When clicking on an internal link, Firefox doesn’t scroll to the position of the anchored / hashtag / # element, during the first page load. Instead, it jumps to the middle or to the bottom of the page. If user clicks inside of the address bar and presses Enter, Firefox then scrolls to the correct position. Problem only occurs when link is not on the same page as the anchored element. If both are on the same page, Firefox scrolls to the correct position. Bug is not present in other browsers.

Example: If you click on link – GetGui DC charging adapter with ammeter New tab opens and Firefox should scroll directly to the element with ID “getgui-current-measuring-adapter”. Instead it scrolls to the middle or to the bottom of the page, as seen in the screenshot below.

firefox-anchor-link-scroll-bug

Problem occurs because Firefox tries to scroll to the anchored element before the page is even loaded and the element is actually created. Since it can’t locate the anchored element, it scrolls to the middle or to the bottom of the page.

(more…)

Read More