Message box having Yes and No Buttons instead of Ok and Cancel buttons

I would like to know whether we can have a message box with Yes and No Buttons in Javascript. I am aware of the confirm message box having OK and Cancel Buttons, but my requirements is for a message box with Yes and No buttons. I am aware that we can define the number of boxes in a message box using VBScript, but i have to give the same functionality using Javascript. Please help asap.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can have the confirm box (as you already know) .The other alternative might be calling a modal
window ( that you create ) and use it.Other alternative being vbscript

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
//Check this, a code posted by another expert in this forum
<script language="JavaScript">
     function alertBox(alertMessage,height,width)
          // This stuff centers the window
          windowWidth = (width == null) ? 200 : width; // width of the new window
         windowHeight = (height == null) ? 30 : height; // height of the new window
         windowLeft = (screen.width / 2) - (windowWidth / 2); // center the window right to left
         windowTop = (screen.height / 2) - (windowHeight / 2); // center the window top to bottom
          // the values get inserted into the features parameter of the command...
          var windowLocation = "top=" + windowTop + ",left=" + windowLeft + ",height=" + windowHeight + ",width=" + windowWidth;
          alertWindow ="","alertWindow",windowLocation);
          alertWindow.document.write("<html><head><title>Alert!</title></head><body bgcolor='#C0C0C0'>");
          alertWindow.document.write("<div align='center'>" + alertMessage + "<br>");
          alertWindow.document.write("<form><input type='button' value=' YES ' onclick='window.close()' align='center'></form>");

// Here is the call:
<input type="button" value="test" onclick="alertBox('This is an alert!!!')">
         alertWindow.document.write("<html><head><title>Alert!</title></head><body bgcolor='#C0C0C0'>");

         alertWindow.document.write("<html><head><title>Alert!</title></head><body bgcolor='buttonface' style='border:0px none'>");

for better appearence.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.