Does this immediately stop execution of the current script
No, the remaining handler script will execute to the end before control returns to the browser and events start happening. When loading of the new page gets far enough for ‘navigation’ to occur, the beforeunload
and unload
events will fire, then the page and any script in it will become inactive.
However, any further queued events and timeouts might not fire. For example if you navigate the page in a click
handler of a form submit button and don’t cancel the default action, it is possible (race condition) for the navigation to occur before the submit
event queued by the default action of the click
.