Wednesday, July 13, 2011

How to maintain window scroll position after closing popup div panel?

I am building a single-page gallery website that has horizontal scrolling. The style has a width of 5000px, so it's the whole page that is being scrolled, not a
. By clicking on thumbnails on the page, a piece of javascript unhides a
to make it appear in front of everything else, similar to a lightbox. It's a pretty simple script that just changes the
from display: none to display: block. Clicking the
's close button toggles the
back to display: none. The problem arises when I scroll my browser window to the right to click one of the buttons in that section of the page. The
pops up without any trouble, but when I click the close button, instead of maintaining the Y coordinates of the page, the browser scroll bar returns to the default position at the far left. There is no reload or refresh taking place, so A: How is this possible? and B: What sort of script do I need to convince my page to stay where I scrolled it to?

No comments:

Post a Comment