作者: 王德田 發表于 2010-09-17 11:40 原文鏈接 閱讀: 6 評論: 0

          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

          評論: 0 查看評論 發表評論

          程序員找工作,就在博客園


          最新新聞:
          · LinkedIn收購ChoiceVendor為IPO醞釀條件(2010-09-23 23:11)
          · HTC HD7硬件規格(2010-09-23 23:00)
          · 時代周報:騰訊 讓硅谷感到寒意(2010-09-23 22:44)
          · Intel處理器、芯片組大降價 幅度達50%(2010-09-23 22:32)
          · 【快樂中秋】大家都來圍觀搜索小白(2010-09-23 22:27)

          編輯推薦:詳解ASP.NET的最新安全漏洞

          網站導航:博客園首頁  個人主頁  新聞  閃存  小組  博問  社區  知識庫


          文章來源:http://www.cnblogs.com/wangdetian168/archive/2010/09/17/showModalDialog.html
          posted on 2010-09-24 00:10 sanmao 閱讀(6652) 評論(0)  編輯  收藏

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


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 玉林市| 吉安县| 九台市| 沂水县| 洞口县| 资溪县| 眉山市| 恩平市| 台湾省| 邹城市| 大渡口区| 漳浦县| 封丘县| 灵山县| 蓝山县| 神木县| 增城市| 伽师县| 天气| 贵德县| 双辽市| 西乌| 永善县| 浦城县| 曲阳县| 蒲江县| 建瓯市| 镇赉县| 宁南县| 新绛县| 梧州市| 樟树市| 浪卡子县| 淅川县| 兴义市| 台中县| 壶关县| 望江县| 乐安县| 金乡县| 博白县|