posts - 108,comments - 56,trackbacks - 0
              1、基本知識(shí) 
          showModalDialog() (IE 4+ 支持)
          showModelessDialog() (IE 5+ 支持)
          window.showModalDialog()方法用來創(chuàng)建一個(gè)顯示HTML內(nèi)容的模態(tài)對(duì)話框。
          window.showModelessDialog()方法用來創(chuàng)建一個(gè)顯示HTML內(nèi)容的非模態(tài)對(duì)話框。


              2、使用方法
          vReturnValue=window.showModalDialog(sURL[,vArguments][,sFeatures]);
          vReturnValue=window.showModelessDialog(sURL[,vArguments][,sFeatures]);


              3、參數(shù)說明
           參數(shù)名稱  性質(zhì)  類型  作用
           sURL  必選  字符串  用來指定對(duì)話框要顯示的網(wǎng)頁的URL。
           vArguments  可選  變體  用來向?qū)υ捒騻鬟f參數(shù)。參數(shù)類型不限。
          對(duì)話框通過window.dialogArguments來取得傳遞進(jìn)來的參數(shù)。
           sFeatures  可選  字符串  用來描述對(duì)話框的外觀等信息

              4、sFeatures參數(shù)說明
           參數(shù)名稱  參數(shù)屬性  說明
           dialogHeight  npx  對(duì)話框高度,不小于100px
           dialogWidth  npx  對(duì)話框?qū)挾?/td>
           dialogLeft  npx  離主窗口左的距離
           dialogTop  npx  離主窗口上的距離
           center  {yes | no | 1 | 0 }  窗口是否居中,默認(rèn)yes
           help  {yes | no | 1 | 0 }  是否顯示幫助按鈕,默認(rèn)yes
           resizable  {yes | no | 1 | 0 }  是否可改變大小,默認(rèn)no
           status  {yes | no | 1 | 0 }  是否顯示狀態(tài)欄,默認(rèn)為yes[ Modeless]或no[Modal]
           dialogHide  { yes | no | 1 | 0 | on | off }  在打印或者打印預(yù)覽時(shí)對(duì)話框是否隱藏,默認(rèn)為no
           scroll  { yes | no | 1 | 0 | on | off }  指明對(duì)話框是否顯示滾動(dòng)條,默認(rèn)為yes
           edge  { sunken | raised }  指明對(duì)話框的邊框樣式,默認(rèn)為raised
           unadorned  { yes | no | 1 | 0 | on | off }  默認(rèn)為no
           注意:dialogHide,edge,unadorned這三個(gè)屬性是用在HTA(HTML Aplication)中的,一般網(wǎng)頁上用不到。


              5、參數(shù)傳遞 通過vArguments來傳遞參數(shù),類型不限制,對(duì)于字符串類型,最大為4096個(gè)字符,也可以傳遞對(duì)象,例如:
          parent.htm
          <script>
          window.showModalDialog("sun.htm","傳遞進(jìn)去的參數(shù)","help:no;scroll:no");
          </script>
          sun.htm
          <script>
          alert("傳來的參數(shù):" + window.dialogArguments);
          </script>


              6、返回值 通過window.returnValue向打開對(duì)話框的窗口返回信息,也可以是對(duì)象。例如:
          parent.htm
          <script>
          result=window.showModalDialog("son.htm","","help:no;scroll:no");
          alert(result);
          </script>
          son.htm
          <script>
          window.returnValue="這里存放返回的結(jié)果";
          </script>


              7、防止在模態(tài)窗口中提交后新開一窗口
             在頁面的 <body>前加入<base target="_self">

              8、調(diào)用父窗口的方法同時(shí)傳遞參數(shù)
          parent.htm
          <script>
          function show(){//父窗口的方法
           alert("show");
          }
          var arg=new Object();//傳遞進(jìn)去的參數(shù)
          arg.win=window;//把當(dāng)前窗口的引用當(dāng)參數(shù)傳進(jìn)去
          arg.str="argument";//要傳進(jìn)去的其他參數(shù)
          window.showModalDialog("son.htm",arg,'help:no');
          </script>
          son.htm
          <script>
          var arg=window.dialogArguments;
          alert(arg.str);
          arg.win.show();//調(diào)用父窗口的方法
          </script>
          posted on 2007-07-07 08:01 破繭而出 閱讀(22792) 評(píng)論(7)  編輯  收藏 所屬分類: JavaScript

          FeedBack:
          # re: 模態(tài)窗口window.showModalDialog
          2009-10-16 16:50 | cenday
          不錯(cuò),清晰明了,我今天也在找showModalDialog之間傳遞參數(shù)和回調(diào)方面的東西,就找到這里來了  回復(fù)  更多評(píng)論
            
          # re: 模態(tài)窗口window.showModalDialog
          2009-10-16 16:51 | cenday
          @cenday
          ...  回復(fù)  更多評(píng)論
            
          # re: 模態(tài)窗口window.showModalDialog[未登錄]
          2010-10-22 11:12 | aaa
          不錯(cuò)  回復(fù)  更多評(píng)論
            
          # re: 模態(tài)窗口window.showModalDialog
          2012-10-15 17:42 | kerenbing
          第七條 應(yīng)該+head里  回復(fù)  更多評(píng)論
            
          # re: 模態(tài)窗口window.showModalDialog[未登錄]
          2012-11-20 12:18 | zzj
          @kerenbing
          +10086  回復(fù)  更多評(píng)論
            
          # re: 模態(tài)窗口window.showModalDialog[未登錄]
          2013-08-02 14:46 | dj
          dfgdfsdfgsdfg  回復(fù)  更多評(píng)論
            
          # re: 模態(tài)窗口window.showModalDialog[未登錄]
          2014-04-28 17:06 | 1

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 新蔡县| 通化市| 墨江| 柏乡县| 湖北省| 曲麻莱县| 永清县| 乌兰察布市| 原阳县| 新乡县| 康平县| 武强县| 梧州市| 阳新县| 景宁| 新龙县| 泗阳县| 仁布县| 呼伦贝尔市| 桑日县| 科尔| 松滋市| 澄江县| 富平县| 大港区| 内乡县| 丰都县| 弥渡县| 米泉市| 涞水县| 卢龙县| 专栏| 靖边县| 隆安县| 嵊泗县| 潞城市| 工布江达县| 泾阳县| 金溪县| 万荣县| 罗田县|