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

Alert, confirm, and prompt not working after using History API on Safari, iOS

This is because of the back-forward cache in Safari. You can use the following code to force a reload when the back-button is pressed. window.onpageshow = function(e) { // e -> event if (e.persisted) { window.location.reload(); } }; Additionally, if you are using jQuery … $(window).bind(“pageshow”, function(e) { // e -> event if (e.originalEvent.persisted) { … 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

how to change url without changing browser history

You’re looking for replaceState(), it replaces the current position in the history instead of pushing a new one, like pushState() does history.replaceState({}, ‘Title’, link.href); from MDN history.replaceState() operates exactly like history.pushState() except that replaceState() modifies the current history entry instead of creating a new one. replaceState() is particularly useful when you want to update the … Read more

Prevent browser scroll on HTML5 History popstate

if (‘scrollRestoration’ in history) { history.scrollRestoration = ‘manual’; } (Announced by Google on September 2, 2015) Browser support: Chrome: supported (since 46) Firefox: supported (since 46) IE: not supported Edge: supported (since 79) Opera: supported (since 33) Safari: supported For more info, see Browser compatibility on MDN.

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)