Alan Alan - 1 year ago 68
Javascript Question

How to bring up an okay / cancel dialog box in Javascript?

When I click on "delete post" on StackOverflow it brings up a window on the screen asking if I want to go ahead or if I want to cancel.

How can I do that in Javascript so that it will work in both a computer and on an IPad?

Answer Source

You can achieve it by using confirm, use the code as below:

<button onclick="myFunction()">Try it</button>
function myFunction() {
confirm("Press a button!");

The above example is very basic, if you some designed confirm box then please check craftpip's jquery-confirm Hope you like it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download