When writing server-side code you need to explicitly stop execution after sending a “Location: …” header to the client or your code will continue to execute in the background.
But what about when you change window.location in a client-side script? Does this immediately stop execution of the current script or is it up to the programmer to make sure that any code located after this call is not reached?
Setting
window.locationdoes not implicitly stop JS execution. Take the following as an example:Try running that from Firebug/Web Inspector/etc. and you’ll notice that the current window will load Google, but a new window will open with Yahoo as well.