In an attempt to solve a similar situation I've come across this example and adapted it. It uses JQUERY UI Dialog as Nikhil D suggested. Here is a look at the code:

HTML:

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<input type="button" id="box" value="Confirm the thing?" />
<div id="dialog-confirm"></div>

JavaScript:

$('#box').click(function buttonAction() {
  $("#dialog-confirm").html("Do you want to do the thing?");

  // Define the Dialog and its properties.
  $("#dialog-confirm").dialog({
    resizable: false,
    modal: true,
    title: "Do the thing?",
    height: 250,
    width: 400,
    buttons: {
      "Yes": function() {
        $(this).dialog('close');
        alert("Yes, do the thing");
      },
      "No": function() {
        $(this).dialog('close');
        alert("Nope, don't do the thing");
      }
    }
  });
});

$('#box').click(buttonAction);

I have a few more tweaks I need to do to make this example work for my application. Will update this if I see it fit into the answer. Hope this helps someone.

Answer from FredFury on Stack Overflow
🌐
W3Schools
w3schools.com › jsref › met_win_confirm.asp
Window confirm() Method
The confirm() method displays a dialog box with a message, an OK button, and a Cancel button. The confirm() method returns true if the user clicked "OK", otherwise false. A confirm box is often used if you want the user to verify or accept something.
🌐
Quora
quora.com › How-do-you-create-a-dialog-with-yes-and-no-options-in-JavaScript
How to create a dialog with “yes” and “no” options in JavaScript - Quora
Answer (1 of 2): In the future, I would strongly recommend Googling questions like this prior to asking. The answer is readily available. You want to use the confirm method. You pass in the message you would like to display in the dialog as the argument like the following [code ]confirm(‘Click y...
🌐
Envato Tuts+
code.tutsplus.com › home › coding fundamentals
Confirm Yes or No With JavaScript | Envato Tuts+ - Code
July 21, 2021 - If a user clicks on the OK button, the confirm method returns true, and if a user clicks on the cancel button, the confirm method returns false. So you can use the return value of the confirm method to know the user's selection.
🌐
O'Reilly
oreilly.com › library › view › javascript-the-definitive › 0596101996 › re482.html
Window.confirm( ): ask a yes-or-no question — JavaScript 1.0: - JavaScript: The Definitive Guide, 5th Edition [Book]
August 17, 2006 - The dialog box contains OK and Cancel buttons that the user can use to answer the question. If the user clicks the OK button, confirm( ) returns true. If the user clicks Cancel, confirm( ) returns false.
Author   David Flanagan
Published   2006
Pages   1018
🌐
PHPpot
phppot.com › javascript › javascript-confirm
JavaScript Confirm Dialog Box with Yes No Alert - PHPpot
February 24, 2024 - The Javascript confirm() function accepts an optional message to be shown on the consent box. It also displays the OK and ‘Cancel’ buttons to allow users to say yes or no about the confirmation consent. This function returns a boolean true or false based on the button clicks on the confirm dialog box.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › confirm
Window: confirm() method - Web APIs - MDN Web Docs
window.confirm() instructs the browser to display a dialog with an optional message, and to wait until the user either confirms or cancels the dialog.
🌐
sebhastian
sebhastian.com › javascript-confirmation-yes-no
JavaScript - Create confirmation box with yes and no options | sebhastian
July 6, 2022 - You can create a JavaScript confirmation box that offers yes and no options by using the confirm() method. The confirm() method will display a dialog box with a custom message that you can specify as its argument.
Find elsewhere
🌐
SitePoint
sitepoint.com › javascript
Yes / No Confirm Alert Box - JavaScript - SitePoint Forums | Web Development & Design Community
December 30, 2005 - Is there a predefined way to display a Message to the user giving them a Yes and No button that is as easy to code as Alert in JavaScript? What I what to do is provide the user a confirm box after the click the delete b…
🌐
TutorialsPoint
tutorialspoint.com › how-to-create-a-dialog-with-yes-and-no-options-in-javascript
How to create a dialog with &ldquo;yes&rdquo; and &ldquo;no&rdquo; options in JavaScript?
July 30, 2019 - To create a dialog with “yes” or “nor”, use a custom dialog box. ... <!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> function functionConfirm(msg, myYes, ...
🌐
Sabe
sabe.io › blog › javascript-yes-no-confirmation-box
How to Create a Yes/No Confirmation Box in JavaScript
February 12, 2022 - The best way to create a yes/no confirmation box is to use the JavaScript confirm() function. This function will make the browser render a dialog box with a message and two buttons, an Ok and a Cancel button.
🌐
ProgrammingBasic
programmingbasic.com › home › javascript › create confirmation alert box with yes and no options - javascript
Create Confirmation Alert Box with YES and NO options - JavaScript | ProgrammingBasic
The box has a Yes and No button with a click event. When any button is clicked, the confirm() function checks if the user has clicked yes or no, depending on the argument that is passed.
🌐
JavaScript in Plain English
javascript.plainenglish.io › how-to-make-a-custom-yes-no-alert-in-javascript-6cd2de221e6c
How to make a custom ‘yes/no’ alert in JavaScript? | by Abhi | JavaScript in Plain English
September 26, 2020 - Here in this script, we have made a dialog with two buttons names yes and no. Which will show only after you click the button with id ‘box’. You can learn more about how to customize these alert boxes in jQuery here: https://jqueryui.com/dialog/ ... New JavaScript and Web Development content every day.
🌐
Coderanch
coderanch.com › t › 119529 › languages › Javascript-Alert-Box-Button
Javascript: Alert Box with Yes/No Button (HTML Pages with CSS and JavaScript forum at Coderanch)
There are scripts out there that build customized confirms, but they are made out of layers (divs) and they do not perform in the "wait here" until user action is complete. ... You can use a div with a higher z-index with your own custom buttons than trying to modify the values in the custom box.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1188726 › how-do-i-create-a-pop-up-yes-no-message-box-called
How do I create a pop up Yes/No message box called from and return the result to C# code? Javascript? Something else? - Microsoft Q&A
If the JavaScript code returns true, then the server side code will run. If the JavaScript code returns false, then the server side button code will not run. Of course the above is simple if you use JavaScript confirm, since it halts code.
🌐
JavaScriptSource
javascriptsource.com › confirm-yes-or-no-with-javascript
Confirm Yes or No With JavaScript - JavaScriptSource
October 5, 2021 - If a user clicks on the OK button, the confirm method returns true, and if a user clicks on the cancel button, the confirm method returns false. So you can use the return value of the confirm method to know the user’s selection.
🌐
EyeHunts
tutorial.eyehunts.com › home › confirm box in javascript with yes no option
Confirm box in JavaScript with yes no option
March 26, 2024 - You can create a JavaScript confirmation box that offers “yes” and “no” options by using the confirm() method. You can specify a custom message as its argument. ... A Simple example code dialog box, there are two buttons: OK and Cancel.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › dialog
The Dialog element - HTML - MDN Web Docs - Mozilla
February 19, 2026 - The HTML <dialog> element is used to create both modal and non-modal dialog boxes. Modal dialog boxes block interaction with other UI elements, making the rest of the page inert, while non-modal dialog boxes allow interaction with the rest of the page. JavaScript can be used to display and close the <dialog> element.