When the alert()
function is called, JS process is interupted by the browser. Therefor you shold use a html-dialog, like @dystroy suggested.
I prefer the jQuery UI Dialog, which is easy to implement. You can define callbacks for buttons, title of the dialog, etc. observe ;)
Here the Link to the API documentation