Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.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_Jquery_Parent Child - Fatal编程技术网

Javascript 停止在额外单击时重新加载子页面

Javascript 停止在额外单击时重新加载子页面,javascript,jquery,parent-child,Javascript,Jquery,Parent Child,单击按钮时,会打开一个子窗口。然后,如果再次单击它,它将重新加载该页面。我试图避免这种情况发生,即使父页面被重新加载。只要子页面“test”处于打开状态,我希望单击事件中的条件对子窗口不做任何操作,并发出警告。这可能吗?谢谢 $('#send').click(function(){ if(*child page already open*){ alert('already open'); }else{ window.open("test.html","Ratti

单击按钮时,会打开一个子窗口。然后,如果再次单击它,它将重新加载该页面。我试图避免这种情况发生,即使父页面被重新加载。只要子页面“test”处于打开状态,我希望单击事件中的条件对子窗口不做任何操作,并发出警告。这可能吗?谢谢

$('#send').click(function(){

   if(*child page already open*){
    alert('already open');
 }else{
        window.open("test.html","Ratting","width=550,height=170,0,status=0,");
      }
});

您需要测试子窗口是否存在且仍处于打开状态:


您需要测试子窗口是否存在且仍处于打开状态:


谢谢大家的代码。除非重新加载父页面,否则这些都可以正常工作。如果重新加载父页面,有没有办法让它工作?谢谢大家的代码。除非重新加载父页面,否则这些都可以正常工作。如果重新加载父页面,是否有办法使其工作?
var childPage = null;
$('#send').click(function(){
  if(childPage && !childPage.closed){
    alert('already open');
  } else{
    childPage = window.open("test.html","Ratting","width=550,height=170,0,status=0,");
  }
});
var childWindow;

$('#send').click(function(){
    if (childWindow && !childWindow.closed) {
        alert('already open');
    } else {
        childWindow = window.open("test.html","Ratting","width=550,height=170,0,status=0,");
    }
});