use*_*429 4 javascript jquery parent-child
我无法弄清楚为什么这不起作用.这段代码有问题吗?正在调用该函数我通过警报检查但它不会关闭窗口.
$('#click').click(function() {
var win = window.open("test3.html","something","width=550,height=170");
});
function closeit(){
win.close();
}
Run Code Online (Sandbox Code Playgroud)
并在test3.html上
window.opener.closeit();
Run Code Online (Sandbox Code Playgroud)
您的win变量的作用域是处理click事件的函数.将它放在该函数和共享的范围内closeit.
在这种情况下,这可能看起来像:
var win;
…
$('#click').click(function() {
win = window.open("test3.html", "something", "width=550,height=170");
});
});
function closeit() {
win.close();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31033 次 |
| 最近记录: |