javascript alert - Javascript Confirm popup Yes, No button instead of OK and Cancel

4 Answers

Unfortunately, there is no cross-browser support for opening a confirmation dialog that is not the default OK/Cancel pair. The solution you provided uses VBScript, which is only available in IE.

I would suggest using a Javascript library that can build a DOM-based dialog instead. Try Jquery UI:

dialog text

Javascript Confirm popup, I want to show Yes, No button instead of OK and Cancel.

I have used this vbscript code:

<script language="javascript">
    function window.confirm(str) {
        execScript('n = msgbox("' + str + '","4132")', "vbscript");
        return (n == 6);

this only works in IE, In FF and Chrome, it doesn't work.

Is there any workround to achieve this in Javascript?

I also want to change the title of popup like in IE 'Windows Internet Explorer' is shown, I want to show here my own application name.

You can also use . It's very simple and easy to use. Just include jquery common library and one more file only:

<script src="" type="text/javascript"></script>
<script src=""></script>
<link rel="stylesheet" href="" type="text/css" />
<script src="jquery.easy-confirm-dialog.js"></script>

The featured (but small and simple) library you can use is JSDialog:

Here is a sample for creating a dialog with Yes and No buttons:

    "Save document before it will be closed?\nIf you press `No` all unsaved changes will be lost.",
    function(result) {
        // check result here

JS Dialog demo screenshot

1) You can download and upload below files on your site

<link href="/Style%20Library/css/smoothness/jquery.alerts.css" type="text/css" rel="stylesheet"/> 

2) after that you can directly use below code

$.alerts.okButton = "yes"; $.alerts.cancelButton = "no";

in document.ready function.

Please try it will work.