2016-07-14 6 views
0

안녕하세요 저는 Laravel에서 일하고 있으며 팝업 창을 열어야하고 팝업 창을 닫은 후 아약스를 호출해야합니다. Firefox에서는 정상적으로 작동하지만 Chrome에서는 처음에는 작동하지만 두 번째에는 작동하지 않습니다. 여기 내 코드입니다 :window.close가 Chrome에서 작동하지 않습니다.

<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); 
} 

내가 코드를 디버깅하기 위해 노력하고 문제 (winchild.closed) 처음의 작동하지만 두 번째 조건이 항상 false의 경우는이 부분에있다.

답변

0

나는 생각하는 방식을 바꾸어야한다고 생각합니다. winchild (팝업)에서 window.opener에 대한 메소드를 트리거하는 unload 이벤트를 작성하십시오. 여기

는 대답한다 :

https://stackoverflow.com/a/1777985/916000

+0

헬로 타하가 제안 주셔서 감사하지만 파이어 폭스에서 잘 작동하지만 window.closed 이벤트가 크롬에서 작동하지 –

관련 문제