4

We use hashes in the url to keep page state in an application (ie like what the focussed tab is). Ala page.html#/tabs:foo/f-name:bar.

When you submit a form on the page, some inconsistencies appear. Chrome will reload the page back with the hash data. Firefox however will go back to whatever the url was when the page was first loaded. (ie if you refresh with a hash, that hash sticks over the form submission)

Which is the 'correct' according to the spec behaviour, and how should we handle it? We wish to preserve this url information and page state over page loads.

Is there a library that deals with this nicely, or should I just be storing/restoring this information out of a temporary cookie?

jhogendorn
  • 5,931
  • 3
  • 26
  • 35
  • 1
    Seems to be similar to http://stackoverflow.com/questions/5283395/url-hash-is-persisting-between-redirects. – mspanc Nov 25 '12 at 15:53

1 Answers1

0

Make a function that you use to change the hash (as opposed to directly changing window.location.hash), and in that function, loop through all the links on the page, removing the old string and appending the argument as the new hash, then update the document.location.hash with the argument.

DanRedux
  • 9,119
  • 6
  • 23
  • 41