Yes and no button in javascript

Posted on 2009-02-12
Last Modified: 2012-06-21
Is it possible to have yes and no button in javascript confirm/alert popups and how?
Question by:ganeshaneesh
    LVL 16

    Accepted Solution

    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.
    LVL 44

    Assisted Solution

    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.


    LVL 16

    Assisted Solution

    You might want to try this link there are some tips in here
    LVL 15

    Assisted Solution

    hum.. two options
    by window.showModalDialog or by vbscript execScript

    reference of showModalDialog
    reference vbscript execScript

    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?");
    window.showModalDialog example

    Open in new window

    LVL 6

    Assisted Solution

    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...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
    Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
    In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
    The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now