Is there an easy way to execute some code AFTER the closing of a window.alert popup? I have a substantially large library to load and my plan was to throw up a welcome message like
window.alert("Welcome to my site!")
just to give the browser a second or two to make sure everything loads. I’m using window.confirm right now, as I can catch the confirm event after the button has been clicked, but there’s really no need for me to have two options. Any suggestions on how to catch the “confirm” on the “Ok” message for window.alert()? Also, will your solution work cross browser (or at least on the later editions of FF, IE, and Safari)?
window.alert()stops the execution flow of the script, so your it’s enough to put your code after the call toalert().Example:
However, if you want to check if “everything” has been loaded, this method will likely not work. Consider using, for example, the body’s onload event handler.
For advanced methods, consider using the jQuery library, which lets you achieve your purpose by means of the
$(document).ready()handler.