How to intercept window.location change

You can use the beforeunload event to trigger your code to run prior to navigation... If you need something more specific (e.g., only navigations initiated in your code), then I recommend that you factor out code changing window.location into a separate function, and add a hook for your custom logic.


You may want to look at Ben Nadel's post in regard to doing this, it may be exactly what you're looking for

Binding Events to non DOM objects with jQuery

His example in the post talks about creating an event handler that triggers a change event when window.location changes