I need to modify some legacy javascript code. There's a place where I want to wait until the user presses one of two buttons and then continue with the program flow (like prompt()
function). How can this be achieved ?
You need to break your function at that point, and add another function to catch the user's button press event.
You can use Narrative Javascript to introduce blocking behavior and simplify it (so you don't need to break up your function into two part), but note that this library has been abandoned since 2013.