html5 - implementing history in web site not working -


here flow of events on web site

  1. go [http://example.com]. web page shows content http://example.com/foo though browser address bar says http://example.com

    the text on web page asks user check out bar. user clicks on link , taken to

  2. [http://example.com/bar]

    the text on web page asks user check out baz. user clicks on link , taken to

  3. [http://example.com/baz]

    the text on web page asks user check out qux. however, user clicks on browser button , taken to

  4. [http://example.com/bar]

    the text on web page asks user check out baz. however, user clicks on browser button , taken ... fail! browser bar should have become [http://example.com] doesn't change @ all.

the code implementing rather straighforward

var goto: function(uri) {     uri via xmlhttprequest     swap content     history.pushstate(null, null, uri); }  window.addeventlistener("popstate", function(event) {     var uri = location.pathname.replace("\/", "");     goto(uri); }, false); 

problem solved. see html 5 history - window.pushstate not working details, short of can't have history.pushstate() inside popstate event. once isolated two, working great.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -