DelphiFAQ Home Search:
General :: Programming :: JavaScript
Code snippets to add functionality to your HTML pages, preferably cross-browser.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Have a Javascript popup display Yes/ No instead of Confirm/ Cancel


I need to ask my web site's user a Yes/ No question. Currently I use JavaScript's confirm() function.
The return value is true (OK) or false (CANCEL).
The word CANCEL is misleading. I want to have the buttons say Yes/ No instead.
How can I do it?


Many people will tell you it is not possible, and that is true for standard Javascript.

However, I found the following which works at least in 32 bit Windows with IE (which often accounts for 95% of your site's users).

This solution uses vbscript's confirm() function.

No, it does not work in FireFox. FireFox will display Confirm/ Cancel.

<script language=javascript>
 /*@cc_on @*/
 /*@if (@_win32 && @_jscript_version>=5)
 function window.confirm(str)
     execScript('n = msgbox("'+str+'","4132")', "vbscript");
     return(n == 6);
 @end @*/
 var r = confirm("Can you do it?");

Generated 16:01:53 on Oct 19, 2017