子页面向父页面传值

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<HTML> 
<HEAD> 
  <TITLE> New Document </TITLE> 
    
    <script type="text/javascript"> 
          
        function openWindow() {  
            var result  = window.showModalDialog("childen.html","DialogHeigth=40,DialogWidth:100px,location:no,menubar:no,toolbar:no,status:no");  
              
            if(result)  
                document.getElementsByName("content")[0].value=result;  
        }  
 
    </script> 
 
</HEAD> 
 
<BODY> 
    <input type="button" value="打开新窗口" onclick="openWindow()"> 
    <hr> 
    这是父窗口<br> 
    <input type="text" name="content" > 
</BODY> 
</HTML> 

子页面

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<HTML> 
<HEAD> 
  <TITLE> New Document </TITLE> 
    
    <script type="text/javascript"> 
        function execute() {  
            window.returnValue = document.getElementsByName("content")[0].value;  
            window.close();  
        }  
    </script> 
</HEAD> 
 
<BODY> 
    <input type="text" name="content" value="这是子窗口"> 
    <input type="button" value="确定" onclick="execute()"> 
</BODY> 
</HTML> 

你可能感兴趣的:(子页面向父页面传值)