window.showModalDialog模式對話框 和 window.open

Java代碼 
  1. window.showModalDialog(url,window,   
  2.   
  3. "help:no;scroll:no;resizable:no;status:0;dialogWidth:420px;dialogHeight:200px;center:yes" );  

1. 
參數1 url,url後面可以接"?name=user"參數 
參數2 傳遞給子窗口的值 可以是window對象,數組 var arry=[],其他變量 類型不限制,對於字符串類型,最大爲4096個字符。也 

可以傳遞對象 

參數3 設置子窗口的高度 ,寬度 等元素 
dialogHeight :對話框高度,不小於100px,IE4中dialogHeight 和 dialogWidth 默認的單位是em,而IE5中是px,爲方便 

其見,在定義modal方式的對話框時,用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。 
下面幾個屬性是用在HTA中的,在一般的網頁中一般不使用。 
dialogHide:{ yes | no | 1 | 0 | on | off }:在打印或者打印預覽時對話框是否隱藏。默認爲no。 
edge:{ sunken | raised }:指明對話框的邊框樣式。默認爲raised。 
unadorned:{ yes | no | 1 | 0 | on | off }:默認爲no。 


2.子父窗口傳值 

在子窗口獲取 父窗口的值 
var param = window.dialogArguments  //獲取傳遞的參數 

如果是 數組或字符串對象 可以在子窗口進行相應操作,例如把該值賦給子窗口的某個元素等等 

如果傳遞的是 父窗口對象 可以通過 param .document.getElementById('checkAllid2'); 獲取父窗口的 
html 元素進行相應的操作 

3.模式對話框提交 
模式對話框如果有form需要提交,提交時會新開一個瀏覽器,所以模式對話框提交時需要提交到 
fream框架頁面 在form元素中加上target="mainFrame"
 

Java代碼 
  1. <form id="myFrom" action="submit.jsp?checkResult=failure" method="post" target="mainFrame">  
  2.  </form>  


target="mainFrame" 是主頁面的 中間框架的id 

主頁面 
Java代碼 
  1. <frameset id="middleframe" rows="95,8,*,30" cols="*"  framespacing="0">  
  2.   <frame src="bannar.jsp" name="topFrame" scrolling="NO" noresize border=0  frameborder=0>  
  3.    <frame src="scollbar.htm" name="ScollbarFrame" scrolling="NO" noresize border=0  frameborder=0 >  
  4.   <frameset id="bodyFrame" rows="*" cols="230,8,*" framespacing="0"  border="0" >  
  5.     <frame src="menu.jsp" name="leftFrame"  scrolling="no" noresize border=0  frameborder=0>  
  6.     <frame src="Scoll.htm" name="ScollFrame" scrolling="NO" noresize border=0  frameborder=0>  
  7.     <frame src="main_tab.jsp" name="mainFrame" id="mainFrame" scrolling="auto"  border=0  frameborder=0><!--   
  8.   
  9. main/main_tab.html -->  
  10.   </frameset>  
  11.   <frame src="bottom.jsp" scrolling="NO"  name="bottomFrame" id="bar" border=0  frameborder=0>  
  12. </frameset>  


4.可以通過window.returnValue向打開對話框的窗口返回信息,當然也可以是對象。例
Java代碼 
  1. parent.htm   
  2. <script>   
  3. str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");   
  4. alert(str);   
  5. </script>   
  6. modal.htm   
  7. <script>   
  8. window.returnValue="http://www.web3.cn";   
  9. </script>   

2.window.open 
window.open打開窗口時 可以打開多個 且焦點不會鎖定在子窗口,仍然能夠操作父窗口。這樣的特點使得某些情況下 
我們最好不要用open打去開一個子窗口 
父窗口打開子窗口代碼 
Java代碼 
  1. window.open(url, "","help=no,toolbar=no,height=330,width=515,top=50,left=50,resizable=no,status=no,toolbar=no,menubar=no,directories ,titlebar=no,location=no");  

參數1.url,url後面可以接"?name=user" 
參數2.彈出窗口的名字(非文件名) 可以爲空 
參數3.設置子窗口的高度 ,寬度 等屬性 

    height=100 窗口高度;  
  width=400 窗口寬度;  
  top=0 窗口距離屏幕上方的象素值;  
  left=0 窗口距離屏幕左側的象素值;  
  toolbar=no 是否顯示工具欄,yes爲顯示;  
  menubar,scrollbars 表示菜單欄和滾動欄。  
  resizable=no 是否允許改變窗口大小,yes爲允許;  
  location=no 是否顯示地址欄,yes爲允許;  
  status=no 是否顯示狀態欄內的信息(通常是文件已經打開),yes爲允許; 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章