html5 - implementing history in web site not working -
here flow of events on web site
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
[http://example.com/bar]
the text on web page asks user check out baz. user clicks on link , taken to
[http://example.com/baz]
the text on web page asks user check out qux. however, user clicks on browser button , taken to
[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
Post a Comment