2017-01-26 8 views
0

IE11에 문제가 있습니다. js에서 새 창을 열고 이전 창에서 이벤트를 바인딩합니다. 그러나 오래된 창이 비활성화되어있을 때는 작동하지 않습니다. 탭을 빠르게 전환 할 때 - 작업하고 또한 window.blur를 사용하여 새 탭에서 포커스를 제거 할 때도 작동합니다. IE는 비활성 탭에 이벤트를 발생하지 않는 것처럼InternetExplorer 11이 비활성 탭에서 이벤트를 실행하지 않는 이유는 무엇입니까?

var win = window.open(url); 
//win.blur(); trash solution 
this.bindLoadEvent(win, function() { 
    element.invoke(); 
}); 

bindLoadEvent: function (win, handler) { 
    if (win.addEventListener) { 
      win.addEventListener('load', handler, true); 
    } else { 
      win.attachEvent('onload', handler); 
    } 
} 

그건 보인다 :

내 코드가있다.

P. 또한 Firefox와 Chrome에서 테스트 해 보았습니다.

+0

이 문서는 https://msdn.microsoft.com/en-us/library/ms537636(v=vs.85).aspx에 있지만 여전히 이벤트를 실행할 수 없습니다. – gado

답변

0

처리기를 연결하기 전에로드 이벤트가 발생할 수 있습니다.

창이 이미 이벤트 핸들러를 연결하기 전에로드 여부를 확인하십시오 : 자세한 내용은

bindLoadEvent = function (win, handler) { 
    if (win.document.readyState === "complete") { 
     setTimeout(handler, 0); 
    } else if (win.addEventListener) { 
     win.addEventListener('load', handler, true); 
    } else { 
     win.attachEvent('onload', handler); 
    } 
    }; 

How to detect if document has loaded (IE 7/Firefox 3)Detecting the onload event of a window opened with window.open 질문을 확인하십시오.