The trouble here is that you can't pause execution in javascript, so you'll need to adjust your confirm function (which you should probably rename, by the way, since JS has a native confirm function). Get rid of the onclick of your yes button, and adjust your confirm function like so:

function confirm(message,nobutton,yesbutton,yesfunction){
  $('#overlaymessage').html(message);
  $('#nobutton').html(nobutton);
  $('#yesbutton').html(yesbutton);
  $('#overlay').show();
  $('#yesbutton').off("click").click(yesfunction);
}

Then, pass a function into your confirm call:

function deleteuser(userid){
  function deleteConfirmed() {
    // delete code here
  }
  confirm('Delete user?','No','Yes',deleteConfirmed);
}
Answer from chug187 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.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ API โ€บ Window โ€บ confirm
Window: confirm() method - Web APIs | MDN
const windowButton = document.querySelector("#windowButton"); const log = document.querySelector("#log"); windowButton.addEventListener("click", () => { if (window.confirm("Do you want to open in new tab?")) { window.open("https://developer.mozilla.org/en-US/docs/Web/API/Window/open"); } else { log.innerText = "Glad you're staying!"; } }); Dialog boxes are modal windows โ€” they prevent the user from accessing the rest of the program's interface until the dialog box is closed.
People also ask

What is the difference between alert() and confirm() in JavaScript?
`alert()` provides a way for the user to acknowledge any information. It displays a simple dialog box with the message and an "OK" button. `confirm()` is useful when you need the user to make a binary decision. It is used to display a dialog box with a message, along with "OK" and "Cancel" buttons.
๐ŸŒ
scaler.com
scaler.com โ€บ home โ€บ topics โ€บ javascript window confirm() method with examples
JavaScript Window confirm() Method with Examples - Scaler Topics
Is the confirm() method supported in all web browsers?
Yes, the `confirm()` method is supported in all major web browsers, ensuring consistent behavior across different platforms.
๐ŸŒ
scaler.com
scaler.com โ€บ home โ€บ topics โ€บ javascript window confirm() method with examples
JavaScript Window confirm() Method with Examples - Scaler Topics
Can I use the confirm() method without attaching it to an event?
Yes, you can use the confirm in JavaScript method without an event, but it's typically employed in response to user actions like button clicks or form submissions for effective interaction.
๐ŸŒ
scaler.com
scaler.com โ€บ home โ€บ topics โ€บ javascript window confirm() method with examples
JavaScript Window confirm() Method with Examples - Scaler Topics
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ javascript-window-confirm-method
Javascript Window confirm() Method - GeeksforGeeks
July 12, 2025 - The confirm() method in JavaScript displays a dialog box with a message and two buttons: OK and Cancel.
๐ŸŒ
PHPpot
phppot.com โ€บ javascript โ€บ javascript-confirm
JavaScript Confirm Dialog Box with Yes No Alert - PHPpot
The JavaScript confirm box is a kind of dialog box. It requires user action to confirm or cancel a recently triggered action. It is the method of the JavaScript window object. There are more functions in JavaScript to display the dialog with ...
๐ŸŒ
Envato Tuts+
code.tutsplus.com โ€บ home โ€บ coding fundamentals
Confirm Yes or No With JavaScript | Envato Tuts+
July 21, 2021 - Since the window object is always implicit, which is to say its properties and methods are always in scope, you can also call the confirm method, as shown in the following snippet. Itโ€™s important to note that the confirmation dialog is modal and synchronous. Thus, JavaScript code execution is stopped when the dialog is displayed, and it is continued after the user dismisses the dialog box by clicking on either the OK or cancel button.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ javascript window confirm() method with examples
JavaScript Window confirm() Method with Examples - Scaler Topics
January 2, 2024 - It is used to display a dialog box with a message, along with "OK" and "Cancel" buttons. The Confirm method is a member of the Window object and is used to prompt the user with a confirmation dialog, offering OK and Cancel options.
Find elsewhere
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ tryit.asp
JavaScript Confirm Box
The W3Schools online code editor allows you to edit code and view the result in your browser
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-to-use-javascript-to-show-a-confirm-message
How to use JavaScript to show a confirm message?
In this tutorial, we will learn how to use JavaScript to show a confirm message. We use window.confirm() method of JavaScript to show a confirm message. A confirm message is enclosed in a confirm dialog box which is a modal window. Such a window take
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_popup.asp
JavaScript Popup Boxes
When an alert box pops up, the user will have to click "OK" to proceed. ... The window.alert() method can be written without the window prefix. ... A confirm box is often used if you want the user to verify or accept something.
๐ŸŒ
Code.mu
code.mu โ€บ en โ€บ javascript โ€บ manual โ€บ dialog โ€บ confirm
The confirm function - box with a confirmation button in JavaScript
The confirm function calls up a confirmation box with OK and Cancel buttons. Returns true if the OK button was pressed, and false if the Cancel button was pressed.
๐ŸŒ
Yahubaba
yahubaba.com โ€บ javascript โ€บ js-confirm-box
JS Confirm Box
We cannot provide a description for this page right now
๐ŸŒ
EDUCBA
educba.com โ€บ home โ€บ software development โ€บ software development tutorials โ€บ javascript tutorial โ€บ javascript confirm
JavaScript Confirm | How Confirm box work in JavaScript
April 12, 2023 - For Time being now we will discuss the confirm box in JavaScript. Confirm box in JavaScript is used to take the permission from the user by clicking the Ok button or Cancel button.
Call ย  +917738666252
Address ย  Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
๐ŸŒ
TutorialsTeacher
tutorialsteacher.com โ€บ javascript โ€บ display-popup-message-in-javascript
JavaScript Message Boxes: alert(), confirm(), prompt()
The confirm() function displays a popup message to the user with two buttons, OK and Cancel. The confirm() function returns true if a user has clicked on the OK button or returns false if clicked on the Cancel button.
๐ŸŒ
Tizag
tizag.com โ€บ javascriptT โ€บ javascriptconfirm.php
Javascript Tutorial - Confirm
Learn how to create a confirm javascript popup box with Tizag.com's Javascript Confirm lesson.
๐ŸŒ
C# Corner
c-sharpcorner.com โ€บ blogs โ€บ using-the-confirm-box-in-javascrip1
Using the Confirm Box in JavaScript
March 22, 2023 - The confirm box in JavaScript is an advanced form of an alert box. It is used to display messages as well as return a value (true or false). The confirm box displays a dialog box with two buttons, OK and Cancel.
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ javascript โ€บ window โ€บ confirm()
JavaScript | window | confirm() | Codecademy
June 17, 2023 - The confirm() method takes in a message parameter that will be displayed in a pop-up window at the current location. The user can select โ€˜cancelโ€™ or โ€˜okโ€™ by default, this information is sent back to the browser as a boolean statement ...
๐ŸŒ
BitDegree
bitdegree.org โ€บ learn โ€บ javascript-confirm
Usage of JavaScript Confirm Method: Confirm Message Explained
September 8, 2017 - The confirm JavaScript box forces the browser to read the message. By doing so, it takes the focus off the current window. This function should not be overused, as it restricts the user from reaching other page parts until the box is closed.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ difference-between-alert-box-and-confirmation-box-in-javascript
Difference between alert box and confirmation box in JavaScript - GeeksforGeeks
June 26, 2024 - Understanding the difference between an alert box and a confirmation box is crucial for effective user interface design and user interaction management. ... The alert function displays a simple message to the user with an "OK" button. It does not require or return any input from the user. Example: To demonstrate the working of the alert box using JavaScript.
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 3000702 โ€บ i-basically-want-to-create-a-custom-confirm-box-in-js-that-return-true-and-false-value
I basically want to create a custom confirm box in js that return true and false value | Sololearn: Learn to code for FREE!
Let value = customconfirmbox(' are you sure'); If(value){}else{} Function customconfirmbox(msg){ //if user click on ok button then return true //else return false Doc.getelbyid('box').innerhtml = msg; //plz dont mind for dom written in short } //html <div> <div> Msg </div> <button>ok</button> <button>cancel</button> </div> javascriptwebsitejs ยท