1. 基本介紹:      
          2.    showModalDialog()    (IE    4+    支持)      
          3.    showModelessDialog()    (IE    5+    支持)      
          4.    window.showModalDialog()方法用來創(chuàng)建一個顯示HTML內(nèi)容的模態(tài)對話框。      
          5.    window.showModelessDialog()方法用來創(chuàng)建一個顯示HTML內(nèi)容的非模態(tài)對話框。      
          6.        
          7.    使用方法:      
          8.    vReturnValue    =    window.showModalDialog(sURL    [,    vArguments]    [,sFeatures])      
          9.    vReturnValue    =    window.showModelessDialog(sURL    [,    vArguments]    [,sFeatures])      
          10.        
          11.    參數(shù)說明:      
          12.    sURL--      
          13.    必選參數(shù),類型:字符串。用來指定對話框要顯示的文檔的URL。      
          14.    vArguments--      
          15.    可選參數(shù),類型:變體。用來向?qū)υ捒騻鬟f參數(shù)。傳遞的參數(shù)類型不限,包括數(shù)組等。對話框通過window.dialogArguments來取得傳遞進來的參數(shù)。      
          16.    sFeatures--      
          17.    可選參數(shù),類型:字符串。用來描述對話框的外觀等信息,可以使用以下的一個或幾個,用分號“;”隔開。      
          18.    1.dialogHeight    :對話框高度,不小于100px,IE4中dialogHeight    和    dialogWidth    默認的單位是em,而IE5中是px,為方便其見,在定義modal方式的對話框時,用px做單位。      
          19.    2.dialogWidth:    對話框?qū)挾取?nbsp;     
          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+]:是否顯示狀態(tài)欄。默認為yes[    Modeless]或no[Modal]。      
          26.    9.scroll:{    yes    |    no    |    1    |    0    |    on    |    off    }:指明對話框是否顯示滾動條。默認為yes。      
          27.    下面幾個屬性是用在HTA中的,在一般的網(wǎng)頁中一般不使用。      
          28.    10.dialogHide:{    yes    |    no    |    1    |    0    |    on    |    off    }:在打印或者打印預(yù)覽時對話框是否隱藏。默認為no。      
          29.    11.edge:{    sunken    |    raised    }:指明對話框的邊框樣式。默認為raised。      
          30.    12.unadorned:{    yes    |    no    |    1    |    0    |    on    |    off    }:默認為no。      
          31.        
          32.    參數(shù)傳遞:      
          33.    1.要想對話框傳遞參數(shù),是通過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("您傳遞的參數(shù)為:"    +    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. 要進行交互操作的前提,在調(diào)用showModalDialog或者showModelessDialog方法的時候,第二個參數(shù)傳window,如:   
          65.   
          66.   
          67. window.showModelessDialog('filename.htm',window,'dialogWidth=200px;dialogHeight=250px;')    
          68.   
          69.   
          70.   
          71. 接下來,就是取得父窗口的一些數(shù)據(jù)和方法,這是經(jīng)常會用的,父窗口取子窗口的參數(shù)一般通過returnValue就可以搞定了~   
          72.   
          73.   
          74. //取得父窗口的JS變量 var   
          75. window.dialogArguments.var;   
          76. //獲得父窗口的對象和屬性   
          77. window.dialogArguments.form1.name.value ;   
          78. //調(diào)用父窗口的方法 fun   
          79. window.dialogArguments.fun() ;    
          80.   
          81.   
          82.   
          83.   
          84. 但是有個問題,在子窗口中的事件響應(yīng)無法調(diào)用父窗口的方法,   
          85.   
          86.   
          87. <button onClick='window.dialogArguments.fun()'>調(diào)父窗口方法</button>    
          88.   
          89.   
          90.   
          91. 不知為何,執(zhí)行上面的方法的時候,窗口會停止響應(yīng)   
          92. http://jackeysion.javaeye.com/blog/464031
          posted on 2010-09-17 11:40 sanmao 閱讀(1396) 評論(0)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 淮安市| 连山| 遵义市| 工布江达县| 十堰市| 花莲县| 襄樊市| 惠州市| 麻城市| 新昌县| 樟树市| 通辽市| 海南省| 海兴县| 古浪县| 丽水市| 榕江县| 漠河县| 尖扎县| 遂川县| 湘阴县| 夹江县| 墨江| 沁源县| 肇州县| 昌都县| 恭城| 苗栗县| 财经| 平遥县| 肃宁县| 大庆市| 汾阳市| 麦盖提县| 昌邑市| 阜宁县| 延边| 北海市| 商河县| 壶关县| 涪陵区|