티스토리 뷰

많은 단순한 것들이다.

보다보면 패턴이 보인다.

부모창에서 팝업을 열면 팝업은 자신이 되지만 팝업을 열었던 페이지는 opener가 됨

팝업을 여는 것은 window.open(~~~)



1. 팝업창 닫기 (ie / 크롬)

self/window.close()를 사용했는데, 크롬에서는 팝업창 닫기에 문제가 있어서.

ie

self.close();

window.close();

크롬

window.open('', '_self').close();


ie는 가리지 않으니 속편하게 window.open('', '_self').close(); 낫다.



2. Form값을 post방식으로 넘겨서 팝업열기

document.popupForm.lp_idx.value = LP_IDX;

document.popupForm.lh_idx.value = LH_IDX;


window.open("", "LecturePOP", "width=720, height=500, scrollbars=yes");

document.popupForm.target = "LecturePOP";

document.popupForm.action = "팝업으로 열 URL";

document.popupForm.submit();


<form name="popupForm" method="post">

<input type="hidden" name="userID" value="<%=CurChild%>">

<input type="hidden" name="lp_idx" value="">

<input type="hidden" name="lh_idx" value="">

</form>


3. 팝업으로

window.open("", "gift", "width=480, height=454, scrollbars=no");

document.theForm.target = "gift";

document.theForm.action = "pop_gift.asp";

document.theForm.submit();


4. 팝업에서 부모창 제어(특정URL로 이동시키기)

opener.location.href = '보낼페이지';





* 윈도우 스케쥴러에서 ie를 열어야지 될때.

스케쥴에서 IE열기

"C:\Program Files\Internet Explorer\iexplore.exe" "url"


닫기

<script type="text/javascript">
<!--
     window.opener = "nothing";
     window.open('', '_parent', '');
     window.close();
//-->
</script>