Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Cancel Button to Javascript Alert

Here is my Javascript Alert:

<script>
function showMessage() {
    setTimeout(function() {
alert("alert");
}, 100);
}
</script>

When a user visits a page, a window pops up that says "alert" and it only has the "Ok" button. When it is clicked, the window goes away and displays the page under it. How do I add a "Cancel" button that has the same effect?

like image 797
Joe Bobby Avatar asked Jul 20 '26 11:07

Joe Bobby


1 Answers

Well you can use window.confirm

confirm("alert");

The above returns true or false based on the selection.

like image 103
Amit Joki Avatar answered Jul 22 '26 01:07

Amit Joki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!