DelphiFAQ Home Search:

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

 

comments66 comments. Current rating: 4 stars (24 votes). Leave comments and/ or rate it.

Question:

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?

Answer:

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?");
alert(r);
</script>

Content-type: text/html

Comments:

You are on page 5 of 5, other pages: 1 2 3 4 [5]
2017-11-27, 19:37:20
anonymous from Indonesia  
Kami sekelurga mengucapkan banyak trimah kasih kpada AKI NUGROHO atas bantuanya no 4d (3569) benar2 tembus 100% bila mau bukti hubungi AKI NUGROHO di nmr ini ;0821=9802=3183; Trma ksh.............


Keywords:
2018-01-21, 10:31:47
Tara from Sweden  
rating
Fantastic goods from you, man. I have keep in mind your
stuff prior to and you are just extremely magnificent.
I actually like what you've obtained right here, certainly like what you're stating and the way in which during which you assert
it. You are making it enjoyable and you still care for to keep it sensible.
I can't wait to read far more from you. That is actually a tremendous site.
2018-01-23, 15:01:45
Lino from Santos, Brazil  
rating
I have checked your blog and i've found some duplicate content, that's why you don't rank high in google's search results, but there
is a tool that can help you to create 100% unique articles, search for;
Boorfe's tips unlimited content
You are on page 5 of 5, other pages: 1 2 3 4 [5]

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: