0
这里是父代码:试图从弹出窗口传递形式值父窗口的JS
<!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或您是否需要一个Web服务来传输值?
这应该让你开始某处:http://stackoverflow.com/questions/4350223/passing-data-between-a-parent-window-and-a-child-popup-window-with-jquery – berentrom
BTW:除非调用函数期望返回值,否则不需要“返回false”。 –