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 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

What are the differences between history.pushState & location.hash? [closed]

location.hash has a better support than the history.pushState method. The advantage of the pushState method is that you can bind a state to the history entry. If you don’t need this state object, I recommend to use the location.hash property, to have better compatibility with older browsers. location.hash=”new-hash”; console.log(history.state); // null or undefined history.pushState({extraData: “some … Read more

SecurityError: The operation is insecure – window.history.pushState()

Make sure you are following the Same Origin Policy. This means same domain, same subdomain, same protocol (http vs https) and same port. How does pushState protect against potential content forgeries? EDIT: As @robertc aptly pointed out in his comment, some browsers actually implement slightly different security policies when the origin is file:///. Not to … Read more

Does Internet Explorer support pushState and replaceState?

Probably the best site for browser compatibility information is CanIUse. Here’s the section on history. Summary – IE9: no, IE10: yes (as of platform preview 3) The first Release Candidate of IE9 (released 10th Feb 2011) does not support history.pushState or history.replaceState. Generally no new features are added after a product gets to RC stage … Read more

Good tutorial for using HTML5 History API (Pushstate?) [closed]

For a great tutorial the Mozilla Developer Network page on this functionality is all you’ll need: https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history Unfortunately, the HTML5 History API is implemented differently in all the HTML5 browsers (making it inconsistent and buggy) and has no fallback for HTML4 browsers. Fortunately, History.js provides cross-compatibility for the HTML5 browsers (ensuring all the HTML5 browsers … Read more

S3 Static Website Hosting Route All Paths to Index.html

It’s very easy to solve it without url hacks, with CloudFront help. Create S3 bucket, for example: react Create CloudFront distributions with these settings: Default Root Object: index.html Origin Domain Name: S3 bucket domain, for example: react.s3.amazonaws.com Go to Error Pages tab, click on Create Custom Error Response: HTTP Error Code: 403: Forbidden (404: Not … Read more