반응형
자식 창에서 부모 창 다시로드
jQuery를 사용하여 자식 창의 부모를 어떻게 다시로드 할 수 있습니까?
이 상황에서는 jQuery가 필요하지 않습니다.
window.opener.location.reload(false);
https://developer.mozilla.org/en-US/docs/Web/API/Window
window.opener , window.parent 또는 window.top 을 사용하여 해당 창을 참조 할 수 있습니다 . 거기에서 reload
메서드를 호출하기 만하면됩니다 (예 :) window.parent.location.reload()
.
그러나주의 사항으로 window.opener
참조가 손실되므로 원래 열린 페이지에서 벗어나야 하는 경우 문제가 있을 수 있습니다.
parent.location.reload();
작동합니다.
단순히 자식 창의 부모 창을 다시로드하려는 경우 : 아래의 줄 코드로 충분합니다.
opener.location.reload();
이전 값 또는 새 값이있는 쿼리 문자열 (요청)로 부모 창을 다시로드하려는 경우. 다음 코드가 작업을 수행합니다.
if (opener.location.href.indexOf('?') > 0) {
var baseUrl = opener.location.href.substring(0, opener.location.href.indexOf('?'));
opener.location.href = baseUrl + "?param1=abc¶m2=123";
}
else {
opener.location.href = opener.location.href + "?param1=abc¶m2=123";
}
이것은 opener.location.reload();
상기 실시 예에서 요구되지 않는다.
top.frames.location.reload(false);
다음을 사용하여 상위 창 위치를 다시로드 할 수 있습니다.
window.opener.location.href = window.opener.location.href;
이것은 나를 위해 일합니다.
window.opener.location.reload()
window.close();
이 경우 현재 탭이 닫히고 상위 탭이 새로 고쳐집니다.
이전 데이터가 다시 제출되는 것을 방지합니다. Firefox 및 Safari에서 테스트되었습니다.
top.frames.location.href = top.frames.location.href;
window.parent.opener.location.reload();
나를 위해 일했습니다.
이것은 작동 할 것이다
window.location.assign(window.location.href);
참고 URL : https://stackoverflow.com/questions/1318006/reload-parent-window-from-child-window
반응형
'IT TIP' 카테고리의 다른 글
"정의로 이동"후에 당신이 어디에서 왔는지 돌아가라는 명령이 있습니까? (0) | 2020.12.10 |
---|---|
Ruby에서 배열을 청크하는 방법 (0) | 2020.12.10 |
C #에서 int에 대한 오버플로 예외가 없습니까? (0) | 2020.12.10 |
드롭 다운 메뉴의 부트 스트랩 3 화살표 (0) | 2020.12.09 |
거꾸로 된 캐럿 (0) | 2020.12.09 |