CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 1999
    Location
    Leeds U.K. (Proud to be Sheffield Born)
    Posts
    202

    msgbox Javascript

    Hi gurus.
    Simple question - I have alert();, which is fine, I have prompt();, which is fine, but how can I duplicate msgbox("whatever", vbYesNo) in javascript?

    I just want to give my users an opportunity to confirm or cancel a delete.

    Any help always gratefully accepted.
    Cheers,
    S. Monkey (Mr.)

  2. #2
    Join Date
    May 2002
    Location
    India
    Posts
    143

    MsgBox in Javascript

    yes javascript has no MsgBox like functionality. still you can use VBScript MsgBox in JS.

    Refer this cade:

    <SCRIPT LANGUAGE=vbscript>
    function callMsgBox2(strMsg)
    'second parameter is msgBox type
    callMsgBox2 = msgBox(strMsg,1)
    end function
    </SCRIPT>

    <SCRIPT LANGUAGE=javascript>
    <!--
    function callMsgBox1(strMsg)
    {
    var retVal = callMsgBox2(strMsg)
    }
    // call this javascript function instead of alert/confirm

    callMsgBox1('This is message box.!')
    //-->
    </SCRIPT>
    Anupam.

  3. #3
    Join Date
    Jan 2002
    Location
    Helsinki, Finland
    Posts
    99
    Personally, I don't recommend using VBScript at all, if you're not certain what kind of environment end-user has.

    Javascript has 3 functions for dialog boxes :
    window.alert() for informational dialogs
    window.prompt() for text-input dialog
    window.confirm() for yes/no dialog

    If you need to do a dialog window with custom content (like yes/no/i'm not sure/just cancel buttons), you should read thread :
    http://www.codeguru.com/forum/showth...hreadid=193184
    Zvona - First aid for client-side web design

  4. #4
    Join Date
    Sep 1999
    Location
    Leeds U.K. (Proud to be Sheffield Born)
    Posts
    202

    Thanks

    Nice one Zvona - confirm is the fellow I was after.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured