js 子窗口赋值到父窗口
js 子窗口赋值到父窗口
父窗口:
<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>
子窗口:
<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>