1. 基本介紹:      
          2.    showModalDialog()    (IE    4+    支持)      
          3.    showModelessDialog()    (IE    5+    支持)      
          4.    window.showModalDialog()方法用來創建一個顯示HTML內容的模態對話框。      
          5.    window.showModelessDialog()方法用來創建一個顯示HTML內容的非模態對話框。      
          6.        
          7.    使用方法:      
          8.    vReturnValue    =    window.showModalDialog(sURL    [,    vArguments]    [,sFeatures])      
          9.    vReturnValue    =    window.showModelessDialog(sURL    [,    vArguments]    [,sFeatures])      
          10.        
          11.    參數說明:      
          12.    sURL--      
          13.    必選參數,類型:字符串。用來指定對話框要顯示的文檔的URL。      
          14.    vArguments--      
          15.    可選參數,類型:變體。用來向對話框傳遞參數。傳遞的參數類型不限,包括數組等。對話框通過window.dialogArguments來取得傳遞進來的參數。      
          16.    sFeatures--      
          17.    可選參數,類型:字符串。用來描述對話框的外觀等信息,可以使用以下的一個或幾個,用分號“;”隔開。      
          18.    1.dialogHeight    :對話框高度,不小于100px,IE4中dialogHeight    和    dialogWidth    默認的單位是em,而IE5中是px,為方便其見,在定義modal方式的對話框時,用px做單位。      
          19.    2.dialogWidth:    對話框寬度。      
          20.    3.dialogLeft:    離屏幕左的距離。      
          21.    4.dialogTop:    離屏幕上的距離。      
          22.    5.center:    {yes    |    no    |    1    |    0    }:窗口是否居中,默認yes,但仍可以指定高度和寬度。      
          23.    6.help:    {yes    |    no    |    1    |    0    }:是否顯示幫助按鈕,默認yes。      
          24.    7.resizable:    {yes    |    no    |    1    |    0    }    [IE5+]:是否可被改變大小。默認no。      
          25.    8.status:    {yes    |    no    |    1    |    0    }    [IE5+]:是否顯示狀態欄。默認為yes[    Modeless]或no[Modal]。      
          26.    9.scroll:{    yes    |    no    |    1    |    0    |    on    |    off    }:指明對話框是否顯示滾動條。默認為yes。      
          27.    下面幾個屬性是用在HTA中的,在一般的網頁中一般不使用。      
          28.    10.dialogHide:{    yes    |    no    |    1    |    0    |    on    |    off    }:在打印或者打印預覽時對話框是否隱藏。默認為no。      
          29.    11.edge:{    sunken    |    raised    }:指明對話框的邊框樣式。默認為raised。      
          30.    12.unadorned:{    yes    |    no    |    1    |    0    |    on    |    off    }:默認為no。      
          31.        
          32.    參數傳遞:      
          33.    1.要想對話框傳遞參數,是通過vArguments來進行傳遞的。類型不限制,對于字符串類型,最大為4096個字符。也可以傳遞對象,例如:      
          34.    -------------------------------      
          35.    parent.htm      
          36.    <script>      
          37.    var    obj    =    new    Object();      
          38.    obj.name="51js";      
          39.    window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");      
          40.    </script>      
          41.   
          42.   
          43.    modal.htm      
          44.    <script>      
          45.    var    obj    =    window.dialogArguments      
          46.    alert("您傳遞的參數為:"    +    obj.name)      
          47.    </script>      
          48.    -------------------------------      
          49.    2.可以通過window.returnValue向打開對話框的窗口返回信息,當然也可以是對象。例如:      
          50.    ------------------------------      
          51.    parent.htm      
          52.    <script>      
          53.        str    =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");      
          54.        alert(str);      
          55.    </script>      
          56.   
          57.   
          58.    modal.htm      
          59.    <script>      
          60.        window.returnValue="http://www.51js.com";      
          61.    </script>    
          62.   
          63. 用window.showModalDialog 或者window.showModelessDialog打開一個模式窗口后,和父窗口的一些交互問題。   
          64. 要進行交互操作的前提,在調用showModalDialog或者showModelessDialog方法的時候,第二個參數傳window,如:   
          65.   
          66.   
          67. window.showModelessDialog('filename.htm',window,'dialogWidth=200px;dialogHeight=250px;')    
          68.   
          69.   
          70.   
          71. 接下來,就是取得父窗口的一些數據和方法,這是經常會用的,父窗口取子窗口的參數一般通過returnValue就可以搞定了~   
          72.   
          73.   
          74. //取得父窗口的JS變量 var   
          75. window.dialogArguments.var;   
          76. //獲得父窗口的對象和屬性   
          77. window.dialogArguments.form1.name.value ;   
          78. //調用父窗口的方法 fun   
          79. window.dialogArguments.fun() ;    
          80.   
          81.   
          82.   
          83.   
          84. 但是有個問題,在子窗口中的事件響應無法調用父窗口的方法,   
          85.   
          86.   
          87. <button onClick='window.dialogArguments.fun()'>調父窗口方法</button>    
          88.   
          89.   
          90.   
          91. 不知為何,執行上面的方法的時候,窗口會停止響應   
          92. http://jackeysion.javaeye.com/blog/464031
          posted on 2010-09-17 11:40 sanmao 閱讀(1396) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 卓资县| 调兵山市| 湘乡市| 安新县| 抚远县| 邮箱| 沙洋县| 乌海市| 鲁甸县| 且末县| 张家港市| 留坝县| 左权县| 政和县| 社旗县| 谷城县| 宜春市| 文成县| 武城县| 曲阜市| 宜君县| 涪陵区| 舞阳县| 河南省| 柳河县| 高雄县| 华池县| 三河市| 美姑县| 扬中市| 田东县| 沭阳县| 璧山县| 临城县| 和平县| 子长县| SHOW| 海安县| 三门峡市| 天峨县| 宁强县|