我有这样的问题。我需要打开弹出窗口按下按钮(此操作已实现)。然后在弹出窗口后,它应该被关闭。
$(document).ready(function() {
$('#popupButton').click(function() {
signinWin = popupwindow([url],
"SignIn",960,630);
signinWin.focus();
signinWin.onload=function(){
var code = getQueryVariable("code");
if(code != null){
signinWin.opener.location.reload(true);
signinWin.close();
}
}
});
});
关闭弹出窗口应该怎么办?导致signinWin.close();没有在onload上工作
答案 0 :(得分:1)
尝试使用字符串window
将第三个参数的height
width
,window.open()
设置为"width=960,height=630"
;利用document.write
关闭window
signinWin
$(document).ready(function() {
$("#popupButton").click(function() {
var signinWin = window.open("/url/", "SignIn","width=960,height=630");
signinWin.focus();
var code = getQueryVariable("code");
if (code != null) {
signinWin.document.write("<script>this.close()<\/script>");
setTimeout(function() {
location.reload(true);
}, 1);
};
});
});
jsfiddle http://jsfiddle.net/scuxhbva/