How to trigger change when using the back button with history.pushstate and popstate?

The popstate only contains a state when there is one. When it goes like this: initial page loaded new page loaded, with state added via pushState back button pressed then there is no state, because the initial page was loaded regularly, not with pushState. As a result, the onpopstate event is fired with a state … 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

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

How to get notified about changes of the history via history.pushState?

5.5.9.1 Event definitions The popstate event is fired in certain cases when navigating to a session history entry. According to this, there is no reason for popstate to be fired when you use pushState. But an event such as pushstate would come in handy. Because history is a host object, you should be careful with … 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