Categories
JavaScript Answers

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

Spread the love

Sometimes, we want to get notified about changes of the history via history.pushState with JavaScript.

In this article, we’ll look at how to get notified about changes of the history via history.pushState with JavaScript.

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

To get notified about changes of the history via history.pushState with JavaScript, we can listen for changes in webNavigation.onHistoryStateUpdated.

To do this, we write

browser.webNavigation.onHistoryStateUpdated.addListener(listener, filter);

to call browser.webNavigation.onHistoryStateUpdated.addListener with the listener to listen for history.pushState calls with the listenr function.

Conclusion

To get notified about changes of the history via history.pushState with JavaScript, we can listen for changes in webNavigation.onHistoryStateUpdated.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *