1

I'm pretty sure I can't do what I'm actually asking, but am wondering if there is some sort of workaround for the issue.

I have a page that has a drop down SELECT form element with several options. If one particular option (in this case, the first item) is selected, we show additional content (via jQuery). This works fine.

What happens, though, is that if I select item 2, the additional content disappears, as it should. I then go to a different page and then hit BACK. A that point, the page properly has kept that additional content hidden (as it was the last state) but the SELECT menu has been reset to the first item. I then have to click the SELECT, pick a different option, then select it again picking the first option, which finally brings the additional content back.

I can't trigger Javascript from what I can tell on a cached page (or is there a way?) Any other clever options?

One option I've come up with is to apply some sort of mouseover action to the area that houses the SELECT menu that does a quick 'reset elements' check. This seems a bit hacky and, of course, will produce an odd screen redraw unexpectedly for people.

DA.
  • 39,848
  • 49
  • 150
  • 213
  • Which browser(s) are concerned? – Simeon Apr 15 '10 at 14:57
  • Do you have to keep any other state on the page? I believe that if you define an onunload event that will keep at least Firefox from using a cached version for the back button. – Tagore Smith Apr 15 '10 at 15:12
  • @Simeon it seems to be Firefox for sure. @Duncan...interesting option. We don't want to break browser cache, ideally, but I'll think about the onunload option some more... – DA. Apr 15 '10 at 15:59

1 Answers1

0

You can record that the user action has taken place and re-execute it using JavaScript. You can store it in a cookie, then check for it on page load and reset the elements you want.

Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176
  • The issue is it appears one can't trigger load events on a cached page. – DA. Apr 15 '10 at 15:02
  • Don't put the initialization in the load, put it inline at the bottom of the page. – Diodeus - James MacFarlane Apr 15 '10 at 17:14
  • Same issue. The page is cached in the browser, so it doesn't actually re-render the page and, therefore, does not execute any inline scripts either. The issue really seems to be Firefox not caching the selected item in the SELECT input. – DA. Apr 15 '10 at 21:49