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'];}?>" />
< a href ="javascript:;" onclick ="openWin('searchPic');" > 圖片 </ a >
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'];}?>" />
< a 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 >
< 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