views:

25982

answers:

5

Javascript Confirm popup, I want to show Yes, No button istead of OK and Cancel. I have use vbscript code

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

this only work in IE, In FF and Chrome, it does't work. Does there any workround to acheive this in Javascript.

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

+16  A: 

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: http://jqueryui.com/

johnvey
+4  A: 

The only way you can accomplish this in a cross-browser way is to use a framework like jQuery UI and create a custom Dialog:

http://jqueryui.com/demos/dialog/

It doesn't work in exactly the same way as the built-in confirm popup but you should be able to make it do what you want.

Phill Sacre
+3  A: 

You can't do this cross-browser with the confirm() function or similar. I highly suggest you use something like the jQuery UI dialog feature to create an HTML dialog box instead.

cletus
A: 

"Paid for by jQuery UI," I gather...

James in Indy
This does not answer the question.
Rob Hruska
jQuery does not need to pay for this. Also if paying worked we all would be using some library built by Microsoft (with such deep pockets they can really afford this, but it is not possible)
TheVillageIdiot
Sorry, was frustrated at the time because javascript couldn't do something so seemingly simple. I have since tried jQuery and become a fan.
James in Indy
+2  A: 

use jQuery Alert http://abeautifulsite.net/blog/2008/12/jquery-alert-dialogs/#demo

$.alerts.okButton = ' Yes ';
$.alerts.cancelButton = ' No ';

see file jquery.alerts.js to change other properties. Thanks...

poseidonJM