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
🌐
Envato Tuts+
code.tutsplus.com › home › coding fundamentals
Confirm Yes or No With JavaScript | Envato Tuts+ - Code
July 21, 2021 - So that’s how you can use the confirm method in JavaScript to present a yes or no selection dialog box.
🌐
SheCodes
shecodes.io › athena › 10106-creating-a-yes-or-no-function-in-javascript
[JavaScript] - Creating a Yes or No Function in JavaScript | SheCodes
Learn how to create a JavaScript function that prompts a user for a yes or no answer and returns a boolean value depending on their response.
🌐
PHPpot
phppot.com › javascript › javascript-confirm
JavaScript Confirm Dialog Box with Yes No Alert - PHPpot
It shows a confirm box with a consent message passed as an argument to the confirm() function. It handles the yes or no options based on the user’s clicks on the OK or ‘cancel’ button of the confirm box.
🌐
W3Schools
w3schools.com › jsref › met_win_confirm.asp
Window confirm() Method
A confirm box is often used if you want the user to verify or accept something. A confirm box takes the focus away from the current window, and forces the user to read the message. Do not overuse this method.
🌐
EyeHunts
tutorial.eyehunts.com › home › javascript prompt yes no
JavaScript prompt Yes No - Tutorial - By EyeHunts
August 23, 2022 - <head> <style> html, body { height: 100%; } .overlay { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0, 0, 0, 0.8); z-index: 2; } .confirm-box { position: absolute; width: 50%; height: 50%; top: 25%; left: 25%; text-align: center; background: white; } .close { cursor: pointer; } </style> </head> <body> <div class="overlay" id="overlay" hidden> <div class="confirm-box"> <div onclick="closeConfirmBox()" class="close">&#10006;</div> <h2>Confirmation</h2> <p>Are you sure to execute this action?</p> <button onclick="isConfirm(true)">Yes</button> <button onclick="isConfi
🌐
sebhastian
sebhastian.com › javascript-confirmation-yes-no
JavaScript - Create confirmation box with yes and no options | sebhastian
July 6, 2022 - <body> <div class="overlay" id="overlay" hidden> <div class="confirm-box"> <div onclick="closeConfirmBox()" class="close">&#10006;</div> <h2>Confirmation</h2> <p>Are you sure to execute this action?</p> <button onclick="isConfirm(true)">Yes</button> <button onclick="isConfirm(false)">No</button> </div> </div> <button onclick="showConfirmBox()">Delete</button> </body> The <button> element will be used to call the dialog box. Next, add the JavaScript code to the page using the <script> tag.
Find elsewhere
🌐
Sabe
sabe.io › blog › javascript-yes-no-confirmation-box
How to Create a Yes/No Confirmation Box in JavaScript | Sabe
February 12, 2022 - HTML<!DOCTYPE html> <html> <head> <title>JavaScript Yes/No Confirmation box</title> <script> const confirmAction = () => { const response = confirm("Are you sure you want to do that?"); if (response) { alert("Ok was pressed"); } else { alert("Cancel was pressed"); } } </script> </head> <body> <button onclick="confirmAction()"> Perform action </button> </body> </html>
🌐
Sololearn
sololearn.com › en › Discuss › 221243 › how-do-i-make-a-choice-of-yesno-in-java-script
How do i make a choice of yes/no in Java script?? | Sololearn: Learn to code for FREE!
You can create two buttons, the first button's value is "yes" and the second button's value is "false". After that, you can use JavaScript and get the value of the button that the user pressed, and then you can make what you want ... var check ...
🌐
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 - Window.confirm( ): ask a yes-or-no question — JavaScript 1.0: · The plain-text (not HTML) string to be displayed in the dialog box. It should generally express a question you want the user to answer
Author   David Flanagan
Published   2006
Pages   1018
🌐
Delft Stack
delftstack.com › home › howto › javascript › javascript alert yes no
How to Alert Yes No With the confirm() Function in JavaScript | Delft Stack
March 11, 2025 - Learn how to use the confirm() function in JavaScript to create interactive yes/no dialogs for user confirmations. This article provides step-by-step instructions, practical examples, and best practices to enhance user experience on your website.
🌐
Codecademy
codecademy.com › forum_questions › 559ecf3e76b8fea08c0002f2
YES/NO prompt prints the console.log for YES only! | Codecademy
You win by a shoelace!”, whereas if I were to literally type anything else other than “yes”, it should print out “Oh no! Bieber shakes his head and sings ‘I set a pace, so I can race without pacing.”. However, this is not the case. Everything else works fluidly, but this is the only issue I’m experiencing in my code. Here’s the full code to help replicate my error: ========================================================== confirm(“Are you ready?”); var age = prompt(“What’s your age?”); if(age < 13) { console.log(“Sure, you can play but I take no legal responsibilit
🌐
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...
🌐
TutorialsPoint
tutorialspoint.com › How-to-create-a-dialog-with-yes-and-no-options-in-JavaScript
How to create a dialog with “yes” and “no” 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, myNo) { var confirmBox = $("#confirm"); ...
🌐
CodeProject
codeproject.com › Questions › 52245 › Creating-a-yes-no-prompt-in-javascript
Creating a yes/no prompt in javascript
April 25, 2016 - Do not try and find the page. That’s impossible. Instead only try to realise the truth - For those who code; Updated: 1 Jul 2007
🌐
JavaScriptSource
javascriptsource.com › confirm-yes-or-no-with-javascript
Confirm Yes or No With JavaScript - JavaScriptSource
October 5, 2021 - How to display a confirm dialog box using JavaScript. The confirm dialog box allows you to perform actions based on the user input.
🌐
W3Schools
w3schools.com › js › js_popup.asp
JavaScript Popup Boxes
When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.