我有一个父窗口,我使用window.open打开子窗口,如下所示.我想从子窗口获取一个布尔值,我将在父窗口中执行我的任务.
function openChildWin()
{
var childWin = window.open("childWin.html", "_blank", "height=400, width=550, status=yes, toolbar=no, menubar=no, location=no,addressbar=no);
if (childWin)
{
//some logic
}
else
{
//some logic
}
}
**childWin.html**
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript">
function OKClicked()
{
//return true; //I want to return true here
window.close(); //Close this child window
}
</script>
</head>
<body>
<button type="button" id="OKButton" onclick="OKClicked()">Click ME</button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
单击按钮时,我想从此处返回true.但这一切都不适合我.我在这里缺乏语法吗?
Ahs*_*hah 11
你可以这样做:
在父母:
function openChildWin() {
var childWin = window.open("childWin.html", "_blank", "height=400, width=550, status=yes, toolbar=no, menubar=no, location=no,addressbar=no");
}
function setValue(val1) {
// do your logic here
}
Run Code Online (Sandbox Code Playgroud)
在弹出窗口中:
function OKClicked() {
window.opener.setValue(true);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28530 次 |
| 最近记录: |