[英]window.close not working in Chrome
Hello I am working in Laravel and I need to open a pop up window and after I close the pop up window, I should make an ajax call. 您好,我在Laravel工作,我需要打开一个弹出窗口,并且在关闭弹出窗口之后,我应该进行ajax调用。 It is working fine in Firefox, but in Chrome it only works the first time but not the second.
它在Firefox中可以正常工作,但在Chrome中它只能在第一次运行,而不能在第二次运行。 Here is my code:
这是我的代码:
<span class="input-group-addon add_btn">
<a onclick="OpenClassRoomNewTab('#/roomno?iframe=true');" id="dayvisitStudents3" class="btn btn-primary">+</a>
</span>
// JavaScript
function OpenClassRoomNewTab(url) {
winchild = window.open(url, '_blank', 'height=500,width=500');
winchild.onunload = function () {
var win = winchild.opener;
if (!winchild.closed) {
win.roomBind();
}
}
}
function roomBind() {
window.setTimeout(function () {
if (winchild.closed) {
$.ajax({
type: 'post',
data: '',
url: '<?php echo url('refreshdropdown'); ?>',
success: function (responseText) {
if (responseText) {
$('#classRoomArea').empty();
$('#classRoomArea').append(responseText.roomno);
}
}
});
}
}, 1);
}
I tried to debug the code and the problem is in this part if (winchild.closed) first time its working but second time condition always false. 我试图调试代码,问题出在这一部分,如果(winchild.closed)第一次工作,但第二次条件始终为假。
I think you should change the way you're thinking. 我认为您应该改变思维方式。 On winchild (the popup), write an unload event, which triggers a method on window.opener.
在winchild(弹出窗口)上,编写一个卸载事件,该事件在window.opener上触发一个方法。
Here it is answered: 在这里回答:
https://stackoverflow.com/a/1777985/916000 https://stackoverflow.com/a/1777985/916000
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.