Cómo detectar un cambio de URL
window.addEventListener('popstate', function (event) {
// The URL changed...
});
Modern Mockingbird
window.addEventListener('popstate', function (event) {
// The URL changed...
});