Add an extra check to popstate/hashchange