어느 가을날의 전환점
JAVASCRIPT|팝업 창에서 부모 창의 함수 호출 방법(opener) 본문
Window opener property
The opener property returns a reference to the window that created the window.
When opening a window with window.open(), you can use this property from the destination window to return details of the source (parent) window.
Coding Tip: window.opener.close() will close the source (parent) window.
Syntax
부모창
var parentWindow;
function openCBAWindow(){
parentWindow = window.open('', 'CbaWindow', 'width=410, height=450, resizable=0, scrollbars=no, status=0, titlebar=0, toolbar=0, left=300, top=200' );
document.reqCBAForm.action = 'XXX.html';
document.reqCBAForm.target = 'parentWindow';
document.reqCBAForm.submit();
}
function testCheck(name, type){
alert("name:"+name+ " | type:"+type);
}
팝업창
try{
window.opener.testCheck('<%=name%>','');
self.close();
}catch(e){
alert("E:"+e);
}
오픈 된 팝업 창 유무에 따른 처리 방법
var openerType = typeof opener.location.href;
if( openerType == 'string' ){
opener.location.href='xxx.html'; //오픈된 팝업창인 경우 부모창(opener)의 페이지 이동
opener.focus();
}else{
window.open(page,'',''); //오픈된 팝업창이 아닌 경우 새 창 열기
}
부모창 > 팝업창1 > 팝업창2 ... 오픈한 경우 opener사용 방법
opener.opener.form1.elements["seq"].value = seq; //팝업창1.부모창.폼1.seq
opener.opener.form1.elements["name"].value = name;
opener.opener.form1.elements["date"].value = date;
window.close(); //현재화면(팝업2) 닫음
opener.window.close(); //팝업1 닫음
# 참조
1) http://www.w3schools.com/jsref/prop_win_opener.asp
'Development' 카테고리의 다른 글
TOMCAT|톰켓 web.xml의 Servlet 로드 옵션 <load-on-startup> (0) | 2012.03.28 |
---|---|
JAVA|자바로 메일 보내기(Apache Commons Email) (0) | 2012.03.20 |
JAVA|자바 소스 코드 분석 툴(잠재적 위험도 분석 등) (0) | 2012.03.07 |
EDITOR|마크다운(Markdown) (0) | 2012.02.15 |
HADOOP|Apache™ Hadoop™(아파치 하둡) (0) | 2011.11.16 |