Popstate on page’s load in Chrome

In Google Chrome in version 19 the solution from @spliter stopped working. As @johnnymire pointed out, history.state in Chrome 19 exists, but it’s null. My workaround is to add window.history.state !== null into checking if state exists in window.history: var popped = (‘state’ in window.history && window.history.state !== null), initialURL = location.href; I tested it … Read more

How do I retrieve if the popstate event comes from back or forward actions with the HTML5 pushstate?

You must implement it yourself which is quite easy. When invoking pushState give the data object a unique incrementing id (uid). When onpopstate handler is invoked; check the state uid against a persistent variable containing the last state uid. Update the persistent variable with the current state uid. Do different actions depending on if state … Read more

How do you access browser history?

Javascript this should get you started: http://www.dicabrio.com/javascript/steal-history.php There are more nefarius means to: http://ha.ckers.org/blog/20070228/steal-browser-history-without-javascript/ Edit:I wanted to add that although this works it is a sleazy marketing teqnique and an invasion of privacy.

How to change the URL displayed in the browser without leaving the page

In older browsers, you can not change the url in the address bar without leaving the page. But you can change the hash portion of the url without leaving the page. That is to say you can change www.example.com to www.example.com#new_text with JavaScript window.location.hash = “new_text”; everything after the # can be changed. However, in … Read more

How to detect when history.pushState and history.replaceState are used? [duplicate]

I used to use this to also be notified of when pushState and replaceState are called: // Add this: var _wr = function(type) { var orig = history[type]; return function() { var rv = orig.apply(this, arguments); var e = new Event(type); e.arguments = arguments; window.dispatchEvent(e); return rv; }; }; history.pushState = _wr(‘pushState’), history.replaceState = _wr(‘replaceState’); … Read more