Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

confirm() with different strings than ok/cancel and focus on cancel??

muscgrmuscgr Posts: 11Member
Hello there!
Do you know a way of writing code to make a confirm pop-up box (using window.confirm() or other code) but having the focus on cancel and not the ok??and is there a way to have something else instead ok/cancel,maybe yes/no,or good/bad etc.???

i would like a popup whenever the user is trying to delete sth so i would like to have the focus on cancel,to prevent him hitting enter key or spacebar by mistake.

thank you very much in advance!!
Yorgos
Athens,Greece

Comments

  • dearmaxdearmax Posts: 36Member
    include a vbscript function

    function myMessageBox(title, prompt, buttons)
    myMessageBox = MsgBox(prompt, buttons, title)
    end function

    Then you can just call this function from any javascript code
    Explanation :
    title
    the title you want your window to be.
    prompt
    The message you want to appear in the dialog.
    buttons
    Group A :
    0 Display OK button only.
    1 Display OK and Cancel buttons.
    2 Display Abort, Retry, and Ignore buttons.
    3 Display Yes, No, and Cancel buttons.
    4 Display Yes and No buttons.
    5 Display Retry and Cancel buttons.
    16 Display Critical Message icon.
    32 Display Warning Query icon.
    48 Display Warning Message icon.
    64 Display Information Message icon.
    Group B :
    0 First button is the default.
    256 Second button is the default.
    512 Third button is the default.
    768 Fourth button is the default.
    Group C :
    0 Application modal. The user must respond to the message box before continuing work in the current application.
    4096 System modal. On Win16 systems, all applications are suspended until the user responds to the message box. On Win32 systems, this constant provides an application modal message box that always remains on top of any other programs you may have running.


    Returned values will be
    1 OK button was clicked.
    2 Cancel button was clicked.
    3 Abort button was clicked.
    4 Retry button was clicked.
    5 Ignore button was clicked.
    6 Yes button was clicked.
    7 No button was clicked.

    Example :
    Here is a sample which shows how to show a dialog with ok and cancel
    with cancel as default. The dialog will remain always on top till
    user clicks on it.



    Test

    function test(){
    myMessageBox("myMsgBox","Do you really want to delete?" , 1 + 256 + 4096 );
    }


    function myMessageBox(title, prompt, buttons)
    myMessageBox = MsgBox(prompt, buttons, title)
    end function






Sign In or Register to comment.