我创建了一个框架集,其中一个框架使用window.open打开一个弹出窗口.在那个打开的窗口中,我有一个表单来收集用户的输入.输入我试图返回到父母但未能做到.任何帮助.我尝试使用window.opener使用此解决方案:弹出窗口在关闭时将数据返回到父级 但未能将getChoice()结果返回到父页面.
框架:
<form>
<button type="button" id="opener" onClick="lapOptionWindow('form.html','', '400','200');">Opinion </button>
</form>
Run Code Online (Sandbox Code Playgroud)
框架js:
function lapOptionWindow(url, title, w, h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
return window.open(url, title,'toolbar=no,location=no,directories=no, status=no, menubar=no, scrollbars=no,resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
Run Code Online (Sandbox Code Playgroud)
form.html(窗口打开):
<div id="lightbox">
<strong>Chinese/Portuguese: Chinese<input type="radio" name="chorpor" value="" id="choice1"> Portuguese<input type="radio" name="chororpor" value="" id="choice2"></strong>
</br><button type="button" id="food" onclick="getChoice()">Submit</button>
</div>
Run Code Online (Sandbox Code Playgroud)
form.js:
function getChoice() {
var choice = "";
var choice1 = document.getElementById("choice1 ");
choice = choice1.checked == true ? "Chinese" : "Portuguese"; …Run Code Online (Sandbox Code Playgroud)