You can either use window.onload
of the destination page (if you have access to modify the code of that page), or you can use window.onunload
to have the alert be launched when unloading the current page. You cannot execute code on the current page after the new page has been loaded.