본문 바로가기

일상

크롬에서 ModalDialog 의 returnValue 를 넘겨주는 방법

 

크롬에서 ModalDialog 의  returnValue 를 넘겨주는 방법

게시판에서 비밀글, 수정, 삭제시 콘트롤하기 위해 ModalDialog를 사용하는데 다른 브라우저에서는 동작하지 않습니다.

이때 가능하게 하는 방법이 아래소스를 추가해주면됩니다.

 

if (oret == undefined)
oret = window.returnValue;

 

if (window.opener)
window.opener.returnValue = 'ok';

 

 

 

-부모창

<script>

function read1_idx(gid,offset,type) {
 if(type != "TRUE") {
  oret = showModalDialog("<?=$mcfg_user_add_page_url3?>/lib/secret.php?idx="+gid+"&tb_name=<?=$table_name?><?=$nx_str?>", "", 'dialogHeight:300px; dialogWidth:200px; dialogLeft:200px; dialogTop:200px; help:no; resizable:no; status:no;scroll:no');

 }
 else {
  oret = "ok";
 }

 if (oret == undefined)
 oret = window.returnValue;

 if(oret != "ok") return;

 window.location = "<?=$PHP_SELF?>?mode=read&start=<?=$start?><?=$nx_str?>&mod_gno="+gid+"&offset=<?=$offset?>&search_str=<?=$search_str?>&search_val=<?=$search_val?>"+"";
 return;
}

</script>

 

 

 

 

-팝업창

<script>
   if (window.opener)
   window.opener.returnValue = 'ok';

  

   window.returnValue='ok';
   window.close();
</script>

 

 

 

모바일에서는 ModalDialog 자체가 먹지 않기때문에 window.open 을 사용해주면됩니다.

지금까지 Chrome 에서 returnValue를 처리하는 방법이었습니다.