简体   繁体   中英

Custom alert/confirmation box

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM