Skip to content
Advertisement

Can I call a function by clicking ‘OK’ in messagebox.showinfo?

I have added a message box in my code and I want to call a function defined earlier when clicking the ‘OK’ button in the message box. Is there any way to achieve this? Thanks in advance.

JavaScript

Advertisement

Answer

When you make a showinfo box, it actually halts your script until you press OK. All you will need to do is put the function you want right after it.

See this example:

JavaScript

If you run that, you will see the print('yeah') only happens when the user clicks OK. So, you can do something similar and call the function where I have put the print.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement