JavaScript - 模式窗口和非模式窗口

1、窗口建立javascript

   非模式窗口showModelessDialog:html

       用法:java

function alertWindowForShowModelessDialog(){
    var childWindow = window.showModelessDialog(
        "dialogWindow.html",
        window,
       "dialogWidth:900px;dialogLeft:100px;Minimize=yes;Maximize=yes;");
}

   模式窗口showModalDialog:less

       特性:dom

           始終得到焦點,即時是最小化,直到關閉ide

       用法:post

function showWindowForShowModalDialog(){
    var childWindow = window.showModalDialog(
        "dialogWindow.html",
        window,
        "dialogHeight: 400px; dialogWidth: 900px; dialogTop: 100px;");
}

2、窗×××互測試

   父窗口對話子窗口:spa

       可經過建立時的句柄childWindow調用子窗口的方法,如:orm

           childWindow.childAlert();


   子窗口對話父窗口:

       可經過建立時傳入的window參數來調用父類窗口中的方法([]爲子窗口層級決定):

           window.dialogArguments[.window.dialogArguments].parentAlert();


3、子窗口刷新

<input type="button" value="刷新"  id="reload_a" href=""></a>
                                                                                                                                          
<script type="text/javascript">
    function reload_self(){
        reload_a.href = "a.html" + "?random="+Math.random();
        reload_a.click();
    }
</script>



4、補充事項

   防止<a/>點擊後打開新頁面的方法:在<head/>之間加入<base target="_self">


   防止<form/>提交以後打開新頁面的方法:

       其一:

           在<head/>之間加入<base target="_self">,若還不能,則在onsubmit中強制本頁面提交:

function onsubmit(){
    document.Form1.target="_self";
}

       其2、

<script type="text/javascript">
     window.name = "curWindow";
</script>
                                                                                                                           
<form name="myForm" id="myForm" action="" method="post" target="curWindow">


   注意:在普通頁面打開非模式窗口,非模式窗口再打開模式窗口時,不能夠調用普通頁面的方法,會卡死(僅測試IE9)


5、參數說明:

   dialogHeight :對話框高度,不小於100px,IE4中默認的單位是em,而IE5中是px

   dialogWidth: 對話框寬度

   dialogLeft: 離屏幕左的距離

   dialogTop: 離屏幕上的距離

   center: {yes | no | 1 | 0 }:窗口是否居中,默認yes,但仍能夠指定高度和寬度

   help: {yes | no | 1 | 0 }:是否顯示幫助按鈕,默認yes

   resizable: {yes | no | 1 | 0 } [IE5+]:是否可被改變大小。默認no

   status: {yes | no | 1 | 0 } [IE5+]:是否顯示狀態欄。默認爲yes[ Modeless]或no[Modal]

   scroll:{ yes | no | 1 | 0 | on | off }:指明對話框是否顯示滾動條。默認爲yes

   dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者預覽時對話框是否隱藏。默認爲no

   edge:{ sunken | raised }:指明對話框的邊框樣式。默認爲raised

   unadorned:{ yes | no | 1 | 0 | on | off }:默認爲no

   minimize:{ yes | no}:指定對話框是否顯示最小化按鈕,默認不顯示

   maximize:{ yes | no}:指定對話框是否顯示最大化按鈕,默認不顯示

相關文章
相關標籤/搜索