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

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


  • 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 :
    the title you want your window to be.
    The message you want to appear in the dialog.
    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.


    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.

Howdy, Stranger!

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


In this Discussion