kapok

          垃圾桶,嘿嘿,我藏的這么深你們還能找到啊,真牛!

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            455 隨筆 :: 0 文章 :: 76 評(píng)論 :: 0 Trackbacks

          http://www.upsaid.com/hase/index.php?action=viewcom&id=69
          因?yàn)闃I(yè)務(wù)系統(tǒng)的特殊性,在web程序中經(jīng)常使用modal dialog,但是showModalDialog只能在IE中使用,于是又麻煩google,終于找到了解決方案: javascript modal dialog.

          為了記憶,把demo的代碼抄錄:


          <html>
          <script language=JavaScript>


          var ModalDialogWindow;
          var ModalDialogInterval;
          var ModalDialog = new Object;

          ModalDialog.value = '';
          ModalDialog.eventhandler = '';


          function ModalDialogMaintainFocus()
          {
          try
          {
          if (ModalDialogWindow.closed)
          {
          window.clearInterval(ModalDialogInterval);
          eval(ModalDialog.eventhandler);
          return;
          }
          ModalDialogWindow.focus();
          }
          catch (everything) { }
          }

          function ModalDialogRemoveWatch()
          {
          ModalDialog.value = '';
          ModalDialog.eventhandler = '';
          }

          function ModalDialogShow(Title,BodyText,Buttons,EventHandler)
          {

          ModalDialogRemoveWatch();
          ModalDialog.eventhandler = EventHandler;

          var args='width=350,height=125,left=325,top=300,toolbar=0,';
          args+='location=0,status=0,menubar=0,scrollbars=1,resizable=0';

          ModalDialogWindow=window.open("","",args);
          ModalDialogWindow.document.open();
          ModalDialogWindow.document.write('<html>');
          ModalDialogWindow.document.write('<head>');
          ModalDialogWindow.document.write('<title>' + Title + '</title>');
          ModalDialogWindow.document.write('<script' + ' language=JavaScript>');
          ModalDialogWindow.document.write('function CloseForm(Response) ');
          ModalDialogWindow.document.write('{ ');
          ModalDialogWindow.document.write(' window.opener.ModalDialog.value = Response; ');
          ModalDialogWindow.document.write(' window.close(); ');
          ModalDialogWindow.document.write('} ');
          ModalDialogWindow.document.write('</script' + '>');
          ModalDialogWindow.document.write('</head>');
          ModalDialogWindow.document.write('<body onblur="window.focus();">');
          ModalDialogWindow.document.write('<table border=0 width="95%" align=center cellspacing=0 cellpadding=2>');
          ModalDialogWindow.document.write('<tr><td align=left>' + BodyText + '</td></tr>');
          ModalDialogWindow.document.write('<tr><td align=left><br></td></tr>');
          ModalDialogWindow.document.write('<tr><td align=center>' + Buttons + '</td></tr>');
          ModalDialogWindow.document.write('</body>');
          ModalDialogWindow.document.write('</html>');
          ModalDialogWindow.document.close();
          ModalDialogWindow.focus();
          ModalDialogInterval = window.setInterval("ModalDialogMaintainFocus()",5);

          }


          </script>

          <script language=JavaScript>


          function YesNoCancel(BodyText,EventHandler)
          {
          var Buttons='';
          Buttons = '<a href=javascript:CloseForm("Yes");>Yes</a>  ';
          Buttons += '<a href=javascript:CloseForm("No");>No</a>  ';
          Buttons += '<a href=javascript:CloseForm("Cancel");>Cancel</a>  ';
          ModalDialogShow("Dialog",BodyText,Buttons,EventHandler);
          }

          function YesNoMaybe(BodyText,EventHandler)
          {
          var Buttons='';
          Buttons = '<a href=javascript:CloseForm("Yes");>Yes</a>  ';
          Buttons += '<a href=javascript:CloseForm("No");>No</a>  ';
          Buttons += '<a href=javascript:CloseForm("Maybe");>Maybe</a>  ';
          ModalDialogShow("Dialog",BodyText,Buttons,EventHandler);
          }

          function YesNoCancelReturnMethod()
          {
          document.getElementById('modalreturn1').value = ModalDialog.value;
          ModalDialogRemoveWatch();
          }

          function YesNoMaybeReturnMethod()
          {
          document.getElementById('modalreturn2').value = ModalDialog.value;
          ModalDialogRemoveWatch();
          }


          </script>

          <BODY >

          <table border=1 cellpadding=2 cellspacing=2 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><a href="javascript:YesNoCancel('Yes, no, or cancel me','YesNoCancelReturnMethod()');">Show Modal #1</a>   
          1. <input type=text id=modalreturn1 name=modalreturn1 value=''></td>

          </tr>
          <tr>
          <td align=left><a href="javascript:YesNoMaybe('Yes, no, or maybe me','YesNoMaybeReturnMethod()');">Show Modal #2</a>   
          2. <input type=text id=modalreturn2 name=modalreturn2 value=''></td>

          </tr>

          </table>

          </BODY>
          </HTML>
          posted on 2005-04-05 09:09 笨笨 閱讀(2092) 評(píng)論(0)  編輯  收藏 所屬分類: HibernateAndSpringALLJ2SE
          主站蜘蛛池模板: 晋州市| 灵武市| 望谟县| 田阳县| 息烽县| 南靖县| 牟定县| 濮阳市| 邯郸县| 金坛市| 龙里县| 鸡泽县| 天台县| 南投县| 德清县| 望奎县| 吉首市| 德州市| 公安县| 郑州市| 邹城市| 彭泽县| 孝义市| 水富县| 贵阳市| 陆河县| 方城县| 金坛市| 墨脱县| 浦东新区| 铁岭市| 八宿县| 东兴市| 津南区| 澄迈县| 固安县| 温州市| 临邑县| 汉源县| 博客| 东光县|