How to handle URL change by JavaScript

Viewed 1541

I know that in modern browsers I can change the URL silently (without page reload) like this:

window.history.pushState(“object or string”, “Title”, “/new-url”);

But I want to be able to detect changes in URL. When user enters the new URL in the address bar how can I handle the event and prevent the page from reloading?

P.S. I know I can use onhashchange but I just don't want to use hashes :)

1 Answers
Related