隨筆 - 147  文章 - 71  trackbacks - 0
          <2009年6月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          常用鏈接

          留言簿(1)

          隨筆分類(146)

          隨筆檔案(147)

          文章分類(28)

          文章檔案(28)

          喜歡的Blog

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

             1、基本知識 
          showModalDialog() (IE 4+ 支持)
          showModelessDialog() (IE 5+ 支持)
          window.showModalDialog()方法用來創建一個顯示HTML內容的模態對話框。
          window.showModelessDialog()方法用來創建一個顯示HTML內容的非模態對話框。


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


              3、參數說明
           參數名稱  性質  類型  作用
           sURL  必選  字符串  用來指定對話框要顯示的網頁的URL。
           vArguments  可選  變體  用來向對話框傳遞參數。參數類型不限。
          對話框通過window.dialogArguments來取得傳遞進來的參數。
           sFeatures  可選  字符串  用來描述對話框的外觀等信息

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


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


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


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

              8、調用父窗口的方法同時傳遞參數
          parent.htm
          <script>
          function show(){//父窗口的方法
           alert("show");
          }
          var arg=new Object();//傳遞進去的參數
          arg.win=window;//把當前窗口的引用當參數傳進去
          arg.str="argument";//要傳進去的其他參數
          window.showModalDialog("son.htm",arg,'help:no');
          </script>
          son.htm
          <script>
          var arg=window.dialogArguments;
          alert(arg.str);
          arg.win.show();//調用父窗口的方法
          </script>
          posted on 2009-06-22 20:55 飛翔天使 閱讀(903) 評論(0)  編輯  收藏 所屬分類: javascript
          主站蜘蛛池模板: 枣阳市| 昭通市| 宁安市| 红河县| 通许县| 柘荣县| 河间市| 于田县| 晴隆县| 贵州省| 襄城县| 法库县| 丁青县| 东丰县| 蓝田县| 东海县| 都江堰市| 茌平县| 永寿县| 长阳| 嘉兴市| 苏州市| 西畴县| 广宗县| 凤阳县| 沙湾县| 建湖县| 广河县| 新巴尔虎左旗| 额尔古纳市| 龙川县| 南部县| 黄大仙区| 葫芦岛市| 海阳市| 通化市| 乐亭县| 乌什县| 元谋县| 信丰县| 马边|