I have a javascript code that is responsible for opening modal popups on my website. It also manipulates the overflow-y
property of the <html>
element by setting it to hidden
. Interestingly, in Chrome and IE, this functionality works as intended. The scrollbar disappears, and the page behind the modal popup retains its scroll position. Upon closing the popup, the overflow-y
property is reverted back to scroll
, keeping the page in its original state and position.
However, in Firefox, once the overflow-y
property is changed to hidden
, the page automatically scrolls to the top. This results in a change in view for the user when the popup is closed, which is not the desired behavior.
You can observe this issue in action by visiting this jsfiddle link
Is there a solution available to resolve this inconsistency in behavior across different browsers?