【发布时间】:2014-02-18 19:13:52
【问题描述】:
这是父代码:
<!DOCTYPE HTML>
<img id="header" src="www.google.com" alt="image">
<input type="text" id="txtName" />
<input type="button" value="Select" onclick="imageReplacement();" />
<script>
function imageReplacement() {
var imager = document.getElementsByTagName("img")[0]
popitup();
}
var popup;
function popitup() {
popup = window.open("Popup.html", "Popup", "width=300,height=100");
popup.focus();
return false
}
</script>
这是弹出代码:
<!DOCTYPE HTML>
<input name="imageNew" id="imageNew"></input>
<br />
<br />
<input type="button" value="Select" onclick="SetName();" />
<script type="text/javascript">
function SetName() {
var txtName = window.opener.document.getElementById("txtName");
txtName.value = document.getElementById("imageNew").value;
window.close();
}
</script>
现在在弹出窗口上设置的任何值都不会传输到父窗口。是否可以使用 javascript 或您需要网络服务来传输值?
【问题讨论】:
-
这应该让你从某个地方开始:stackoverflow.com/questions/4350223/…
-
顺便说一句:除非调用函数期望返回值,否则您不需要“return false”。
标签: javascript html popup parent-child