DelphiFAQ Home Search:

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

 

comments60 comments. Current rating: 4 stars (19 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 4 of 4, other pages: 1 2 3 [4]
2010-04-17, 13:53:50
timicndolok@hotmail.co.uk from United Kingdom  
rating
Well Jvascript Dosent Do Yes Or No Properly Although Visual Basic Script Can. I Can Give You An Exaple. This One Is An Comfirm One:



x=msgbox ('Your User Account Has No Settings And May Cause Data Loss To Your Computer. Do You Want To Enable ?', 4+48,' User Account Warning')
if x=6 then
msgbox 'Your User Accont Settings Are Now Enabled', 0,'Enabled'
elseif x=7 then
msgbox 'Your User Account Settigs Has Been Left Until Further Notice', 0,'No Change'
end if



Tryed It?, Didnt Work? Then Eamil Me At The Adress
2011-12-15, 05:53:11
anonymous from India  
jvb
2012-01-27, 06:57:18
anonymous from India  
rating
thank you very much..It works well
but how can I get a new line
When I use '\n' in my message(str)
It show an error 'Unterminated string constant'

http://tutorialsmad.com
2012-06-09, 00:25:47
anonymous from Washington, United States  
New line is vbCrLf in VBScript.
2013-01-11, 01:19:28
anonymous from New Delhi, India  
fff
2013-02-28, 13:28:18
anonymous  
rating
2014-07-23, 13:44:23
anonymous from United States  
rating
I just love it. Thanks :)
2014-10-24, 14:29:57
anonymous from Pakistan  
Working inside the cutting edge restorative consideration offices presupposes http://www.essaythinker.net/ having the key and exceptionally exceptional understanding of what you learn amid your therapeutic studies.
2014-10-30, 17:09:46
anonymous from Pakistan  
This is on account of lion's share of them are involved with different commitments of life and are not continually going to the classes. It is conceivable that http://www.smartcus..iting.net/ most understudies will surrender along the way.
2014-12-28, 06:35:20
anonymous from Venezuela  
What does this system wannirg BLUE SCREEN message mean?Hello, i was using my laptop just now , i did a registry leftovers cleanup with CCleaner, and was also downloading big file with torrent program. computer harddisk is 90% occupied. Then all of a sudden my Window screen turned into a primitive blue screen with a few lines of programing codes on the top and a message saying : Your computer will be restarted to prevent damage to your system . If this is the first time you see this screen please bla bla bla . The scary part is at the bottom of this blue screen there's a message with a percentage counting, saying: Begin dumping of physical memory 10% 20% 30% .. [percentage keeps counting up...]I was very afraid of the Begin dumping of physical memory part, thinking is the system starting to delete my harddisk memory?? so i just unplugged the power chord and turned off the computer not letting the percentage finish counting to 100. When i restarted my computer/windows. There's a Microsoft Windows saying : The system has recovered from a serious error , along with an error signature with some technical error codes.What exactly happened just now in the Blue Screen ????? what's dumping of physical memory? what do i need to do now??
2014-12-28, 17:42:07
anonymous from Caracas, Venezuela  
When you watch the Texans’ DE play, its easy to be impressed with his attiehlc ability, speed up the field and his power at the point of attack. That’s legit talent right there. But let’s not forget about the technique Watt displays with his hands. He can “press” an offensive lineman and create some separation to work his counter moves. Fast and violent with the hands. That’s what I took from the game. CSS10-26
2014-12-29, 07:38:00
anonymous from Venezuela  
The real name is The Blue Screen Of Death'. Don't be scared of it, it will NOT bring a virus on or<a href=' http://fdaszzhzqg.com'> ahnyting</a> similar to that. If you don't want `a virus, simply wait for it to reach 100%. Its just tricking you with the dumping of physical memory' bit. It will not wipe the memory off your computer at all! I'm not an expert at this so ill just ask my father for some help, because we have 4 computers in our house and he know what to do when something goes wrong!Don't worry!Sincerely-Alix M
2015-04-05, 22:07:01
dukun santet from Indonesia  
rating
2015-04-05, 22:07:34
dukun santet from Indonesia  
rating
2015-04-05, 22:08:03
dukun santet from Indonesia  
You are on page 4 of 4, other pages: 1 2 3 [4]

 

 

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: