[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 776
  • Last Modified:

Yes and no button in javascript

Is it possible to have yes and no button in javascript confirm/alert popups and how?
Thanks,
Aneesh.
0
ganeshaneesh
Asked:
ganeshaneesh
5 Solutions
 
sunithnairCommented:
I dont think it is possible to have the buttons named as "Yes", "No" in the alert/confirm functions because the browsers does not allow to change the default dutton names.
0
 
TimCotteeCommented:
Hello ganeshaneesh,

Not necessarily with the standard dialogs. The button text is controlled by the browser/operating system itself and not by anything that you can control. You can however create a popup that can used to give you more control over what is displayed. These can be modal dialogs or where this is not supported can be made to simulate this.

Regards,

TimCottee
0
 
sunithnairCommented:
You might want to try this link there are some tips in here http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21182622.html
0
 
fsze88Commented:
hum.. two options
by window.showModalDialog or by vbscript execScript

reference of showModalDialog
https://developer.mozilla.org/en/DOM/window.showModalDialog
reference vbscript execScript
http://www.delphifaq.com/faq/javascript/f1172.shtml

note : vbscript execScript is only works on IE.... stated on vbscript reference url..
showModalDialog is works on IE,FF more complex than vbscript execScript
vbscript example
<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 = window.confirm("Can you do it?");
alert(r);
</script>
 
window.showModalDialog example
https://developer.mozilla.org/samples/domref/showModalDialog.html

Open in new window

0
 
dnunes_brCommented:
The confirm and alert dialog boxes of standard javascript can't be changed. There are other ways you can show a custom window, but you will need to do it by yourself or use some third party javascrip library/framework, such as YUI, Dojo, Scriptaculous, JQuery, etc...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now