Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当父窗口用户注销时关闭特定子窗口_Javascript_Php_Codeigniter_Window.open - Fatal编程技术网

Javascript 当父窗口用户注销时关闭特定子窗口

Javascript 当父窗口用户注销时关闭特定子窗口,javascript,php,codeigniter,window.open,Javascript,Php,Codeigniter,Window.open,我有一个网站,点击一个按钮就会在子窗口中打开用户 var childWindow=window.open('<?=$this->config->item('base_url').'after_login/portfolio' ?>', 'bypassed_user_window','height=' + screen.height + ',width=' + screen.width + ',resizable=yes,scrollbars=yes,toolbar=ye

我有一个网站,点击一个按钮就会在子窗口中打开用户

 var childWindow=window.open('<?=$this->config->item('base_url').'after_login/portfolio' ?>', 'bypassed_user_window','height=' + screen.height + ',width=' + screen.width + ',resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes');
var childWindow=window.open(“”,'bypassed_user_window','height='+screen.height+',width='+screen.width+',resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes');
现在,我想在父窗口用户注销时关闭这个子窗口。 我正在使用Codeigniter。
如果我给出
childWindow.close()
在我的控制器中,它提供了未定义的
子窗口
,这是预期的。那么现在怎么关窗户呢。谢谢大家!

子窗口
确实是
未定义的
。因此,为了实现您正在尝试的操作,您需要对该窗口对象的引用。您可以尝试以下方法:

<script type="text/javascript">
    var childWindow = window.open('', 'bypassed_user_window');

    if (childWindow !== null) {
        childWindow.close();
    }
</script>

var childWindow=window.open(“”,“绕过用户窗口”);
if(childWindow!==null){
childWindow.close();
}
首先,我不能100%确定这是否适用于所有浏览器,但如果您指定与以前相同的名称,则应该得到相同的窗口。如果返回此对象的相同引用,则取决于原始窗口和打开的窗口中使用的域/端口。如果关闭此窗口不起作用,可以将此窗口发送到另一个URL,在该URL中关闭窗口本身。有关更多信息,请参阅(并查看本页上提到的同一原产地政策,以检查您是否可以执行您想执行的操作)