I am implementing an automated synchronous javascript sequencer. All events are correctly resolved synchronously, but there is a problem when I trigger an event that causes change of URL (for example clicking on <A> element). The event is resolved, but following steps are performed immediately (I need the sequencer to stop at this point and the rest of the sequence should continue upon loading of new page).
How can I detect, that the URL is about to be changed, so I can tell the sequencer to stop?