js 子窗口赋值到父窗口

js 子窗口赋值到父窗口

 

父窗口:javascript

 

< script >
function  openWin(str) {
    window.open(siteurl
+ " popup/ " + str,  null , ' width=800,height=500 ' ); // 打开窗口

</ script >  
< input  type ="text"  id ="title"  name ="picPath"  value ="<?php if(isset($pic)) {echo $pic['Path'];}?>"   />  
< href ="javascript:;"  onclick ="openWin('searchPic');" > 图片 </ a >

 

 

子窗口:php

< html >
    
< head >
        
< title > 图片搜索 </ title >
    
</ head >
    
< body >
        
< script >
            
function  getValue() {
                window.opener.document.getElementById(
' title ' ).value  =  document.getElementById( ' picPath ' ).value // 赋值
                window.close(); // 关闭窗口
            }
        
</ script >
        
< input  type ="text"  id ="picPath"   />
        
< input  type ="button"  value ="肯定"  onclick ="getValue()"   />
    
</ body >

</html> html