Reputation: 238
Is it possible to make a custom alert/confirm/prompt
that have the same behaviour as native javascript windows (without using callbacks/asynchronous events)?
Ex.:
if(mytest == true){
myCustomMsgWindow('message'); //Pause execution
//do something
}
I tried this once but dint works for confirm window because it must return a value.
Upvotes: 0
Views: 400
Reputation: 92274
No, you cannot write JS code that blocks (pauses execution) waiting for user input on without alert
or confirm
. You have to listen for events within your dialog asynchronously (through events)
The solution is use callbacks as you have already mentioned, not sure why you don't want to use that.
Upvotes: 1
Reputation: 4775
You can make custom ones but their behavior will not be the same.
Because in the browsers these boxes pause the execution thread, and resumed by user action. you can not pause the execution thread, this is implicit.
However there are some workaround which may behave almost similar. You can try that BootBox
Upvotes: 1