Skip to content

pushState does NOT fire popstate #30178

@mtkopone

Description

@mtkopone

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/History/pushState

What specific section or headline is this issue about?

History: pushState() method

What information was incorrect, unhelpful, or incomplete?

The page says: "Add a listener for the popstate event in order to determine when the navigation has completed. The state parameter will be available in it."

Yet the popState page (https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event) says: Note that just calling history.pushState() or history.replaceState() won't trigger a popstate event. The popstate event will be triggered by doing a browser action such as a click on the back or forward button (or calling history.back() or history.forward() in JavaScript).

_

What did you expect to see?

I'd expect it to say e.g. "You cannot listen for state changes using popstate, so maybe you should reconsider your entire approach."

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions