Pop up problem!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tea Maker
    New Member
    • Jul 2007
    • 45

    Pop up problem!

    Hi,
    Does anybody know how to convert the following code, so that I the popup will have buttons instead of anchor tags?

    Here's the code:


    [CODE=html]<html>
    <script language=JavaSc ript>

    var ModalDialogWind ow;
    var ModalDialogInte rval;
    var ModalDialog = new Object;

    ModalDialog.val ue = '';
    ModalDialog.eve nthandler = '';


    function ModalDialogMain tainFocus()
    {
    try
    {
    if (ModalDialogWin dow.closed)
    {
    window.clearInt erval(ModalDial ogInterval);
    eval(ModalDialo g.eventhandler) ;
    return;
    }
    ModalDialogWind ow.focus();
    }
    catch (everything) { }
    }

    function ModalDialogRemo veWatch()
    {
    ModalDialog.val ue = '';
    ModalDialog.eve nthandler = '';
    }

    function ModalDialogShow (Title,BodyText ,Buttons,EventH andler)
    {

    ModalDialogRemo veWatch();
    ModalDialog.eve nthandler = EventHandler;

    var args='width=350 ,height=125,lef t=325,top=300,t oolbar=0,';
    args+='location =0,status=0,men ubar=0,scrollba rs=1,resizable= 0';

    ModalDialogWind ow=window.open( "","",args) ;
    ModalDialogWind ow.document.ope n();
    ModalDialogWind ow.document.wri te('<html>');
    ModalDialogWind ow.document.wri te('<head>');
    ModalDialogWind ow.document.wri te('<title>' + Title + '</title>');
    ModalDialogWind ow.document.wri te('<script' + ' language=JavaSc ript>');
    ModalDialogWind ow.document.wri te('function CloseForm(Respo nse) ');
    ModalDialogWind ow.document.wri te('{ ');
    ModalDialogWind ow.document.wri te(' window.opener.M odalDialog.valu e = Response; ');
    ModalDialogWind ow.document.wri te(' window.close(); ');
    ModalDialogWind ow.document.wri te('} ');
    ModalDialogWind ow.document.wri te('</script' + '>');
    ModalDialogWind ow.document.wri te('</head>');
    ModalDialogWind ow.document.wri te('<body onblur="window. focus();">');
    ModalDialogWind ow.document.wri te('<table border=0 width="95%" align=center cellspacing=0 cellpadding=2>' );
    ModalDialogWind ow.document.wri te('<tr><td align=left>' + BodyText + '</td></tr>');
    ModalDialogWind ow.document.wri te('<tr><td align=left><br> </td></tr>');
    ModalDialogWind ow.document.wri te('<tr><td align=center>' + Buttons + '</td></tr>');
    ModalDialogWind ow.document.wri te('</body>');
    ModalDialogWind ow.document.wri te('</html>');
    ModalDialogWind ow.document.clo se();
    ModalDialogWind ow.focus();
    ModalDialogInte rval = window.setInter val("ModalDialo gMaintainFocus( )",5);

    }

    </script>

    <script language=JavaSc ript>


    function YesNo(BodyText, EventHandler)
    {
    var Buttons='';
    Buttons = '<a href=javascript :CloseForm("Yes ");>Yes</a> ';
    Buttons += '<a href=javascript :CloseForm("No" );>No</a> ';
    ModalDialogShow ("Dialog",BodyT ext,Buttons,Eve ntHandler);
    }



    function YesNoReturnMeth od()
    {
    document.getEle mentById('modal return1').value = ModalDialog.val ue;
    ModalDialogRemo veWatch();
    }



    </script>

    <BODY >

    <table border=0 cellpadding=0 cellspacing=0 align=center width="60%">
    <tr><td align=left></td></tr>
    <tr><td align=left></td></tr>
    <tr><td align=left></td></tr>
    <tr>

    <td align=left>
    <input type=text id=modalreturn1 name=modalretur n1 value=''>
    <a href="javascrip t:YesNo('Are You Sure?',
    'YesNoReturnMet hod()');">Click To Confirm</a>
    </td>
    </tr>


    </table>

    </BODY>
    </HTML>[/CODE]


    Thanks in advance.
    Last edited by gits; Jul 24 '07, 07:58 AM. Reason: added CODE tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    hi ...

    you have to replace the YesNo-method with:

    [CODE=javascript]
    function YesNo(BodyText, EventHandler)
    {
    var Buttons='';
    Buttons = '<input type="button" onclick="CloseF orm(\'Yes\')"; value="Yes"/>';
    Buttons += '<input type="button" onclick="CloseF orm(\'No\')"; value="No"/>';
    ModalDialogShow ("Dialog",BodyT ext,Buttons,Eve ntHandler);
    }
    [/CODE]

    and please use code tags when posting code

    kind regards

    Comment

    • Tea Maker
      New Member
      • Jul 2007
      • 45

      #3
      Originally posted by gits
      hi ...

      you have to replace the YesNo-method with:

      [CODE=javascript]
      function YesNo(BodyText, EventHandler)
      {
      var Buttons='';
      Buttons = '<input type="button" onclick="CloseF orm(\'Yes\')"; value="Yes"/>';
      Buttons += '<input type="button" onclick="CloseF orm(\'No\')"; value="No"/>';
      ModalDialogShow ("Dialog",BodyT ext,Buttons,Eve ntHandler);
      }
      [/CODE]

      and please use code tags when posting code

      kind regards
      Wow!! Gits i'm always so impressed by you. Thank you so much, you're the best man ;)

      One more issue stuck, is it possible to prevent the user from pressing the close button?

      Regards

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5388

        #4
        ;) ... not the best at all ;)) ... but quite good *lol*

        to your question: no ... that is not possible but you may use an onbeforeunload-event-handler to do an action when the user closes the window.

        kind regards

        Comment

        • Tea Maker
          New Member
          • Jul 2007
          • 45

          #5
          Originally posted by gits
          ;) ... not the best at all ;)) ... but quite good *lol*

          to your question: no ... that is not possible but you may use an onbeforeunload-event-handler to do an action when the user closes the window.

          kind regards
          Hehe okay thanks Gits, I still believe you're the best ;)

          Regards,
          Wassim

          Comment

          Working...