[Javascript] 팝업창에서 부모 frame 접근

2014. 5. 8. 15:03프로그래밍/Javascript & JQuery

1. 부모 frame "1" 에서 팝업 호출

2. 팝업창에서 insert 등의 프로세스 수행

3. 팝업창을 닫고 부모 frame "2"에서 데이터 조회


아래와 같은 그림




4. 소스

  1) frame1.html

    <frameset cols = "130" frameborder="no" border = "0">

 <frame src="menu.html" name="left">

 <frame src="searchComplete.html" name="right">

    </frameset>

  2) menu.html

    <html>

      <head>

<title>menu </title>

<script type="text/javascript">

function openPop(){

window.open("popup.html", "_target", "scrollbars=yes, resizable=no, menubar=no, width=700, height=500");

}

</script>

     </head>

     <body>

<a href="javascript:openPop();">openPopup</a>

</body>

  </html>

  3) popup.html

   <html>

      <head>

<title>main </title>

<script type="text/javascript">

function search(){

opener.parent.frames["right"].location="데이터삽입등의프로세스URL";

// 알아두어야 할 것 opener와  parent의 차이

// - Parent는 frame에서 사용하며, Opener는 팝업창에서 사용한다.

self.close();

}

</script>

     </head>

     <body>

<a href="javascript:search();">조회</a>

</body>

  </html>

  4) searchComplete.html

     - 리스트 조회 결과페이지 작성