javascript 父子窗口傳值

父窗口:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
<title>無標題文檔</title>  
  
</head>  
<body>  
    <input   type="button"   id="test"   οnclick="window.showModalDialog('1.htm',window,'');"   value="點我"> 
</body>  
</html>  


 

子窗口:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
<title>無標題文檔</title>  
<script language="javascript">  
    // 子窗口給父窗口賦值(模態)   
    function test_parent() {   
        // 獲得父窗口的對象   
        	window.returnValue='aaa';
 	window.close();           //關閉模態窗口
    
    }          
</script>  
</head>  
<body>  
     <script   language="javascript">   
  	function   test()   
  	{   
  		window.dialogArguments.document.all["test"].value   =   document.all["txt_Value"].value;   
  		window.close();   
  	}   
  </script>   
  <input   id="txt_Value">   
  <input   type="button"   οnclick="test();"   value="提交">   

</body>  
</html>  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章