How do I keep the state of the page on the back button, but reset it if visited in some other way?

I am working on a mobile commerce site and there is an annoying quirk in the navigation pages.

The navigation page for each product category shows links for all subcategories, which work pretty much as you would expect, with the exception of the Show All subcategory. If the user clicks that link, instead of going to a page outside of the page, the subcategory menu collapses to reveal the first product page (which was there but was cleverly hidden).

The problem is that if the user visits a product from that page and returns, the page is reset to "Show-Nav-Don't-Show-Products" - not what the user expects. I could set a cookie so that this page remains "Show-Products-Don't-Show-Nav" after it has been placed in this state, but this creates unintuitive behavior if the user navigates back through other means (eg , memorial services, or home page revisit) and would like to see a list of subcategories instead of products.

I tried to set the margin hidden

on the nav page to be set when expanding products, on the theory that it will retain its value if you visit the page through "Back", but get reset if it is loaded any other way. This only works in Chrome; it doesn't work in Safari and other mobile browsers.

I would agree that it detects when a user visits a page using the back button and does what should be a fairly accurate guess of what state the user is expecting, but questions like this ( Can I detect when user gets to the page using the back button? ) make me think there is no good way to detect when a user came in via the back button.

Obviously this is not a very good design. But given that my job is to find bugs, I'm looking for a low impact solution that I can minimize both the time I spend and the chance of regression errors, so refactoring the code isn't a good solution.

Does anyone have any ideas on how they approach this problem? For what it's worth, I have access to jQuery on this page.

+3


source to share





All Articles