2009-11-13 5 views
0

나는 내 cakephp에서 내 페이지 중 하나를 열 수있는 popupwindow를 만듭니다. 이 팝업은 다른 페이지로 연결되는 양식입니다. '제출'버튼을 클릭하면 자동으로 데이터를 MySQL에 저장하고 닫을 것입니다.제출 버튼을 클릭하면 내 팝업 창을 닫는 방법?

제출 버튼을 클릭하면 팝업 창이 닫힙니다. 내가 top.close() 설정; 그러나 아무 기능도하지 말라. 나는()가 없습니다 무엇

..

<script type="text/javascript"> 

    function popup(mylink, windowname){ 
    if (! window.focus)return true; 
     var href; 
    if (typeof(mylink) == 'string') 
     href=mylink; 
    else 
     href=mylink.href; 
    window.open(href, windowname, 'width=800,height=1200,scrollbars=yes'); 
    return false; 
    } 
    </script> 
    <p><A HREF="http://.../index.php/products/add" onClick="return popup(this, 'notes');top.close();">Add Products</A></p> 
+0

자바 스크립트로이 태그를하시기 바랍니다. – fserb

답변

1

window.open()는 새로운 윈도우에 대한 참조를 반환합니다. 그러면 다음을 수행 할 수 있습니다.

my_win = window.open(...); 
[...] 
my_win.close(); 
+0

함수 팝업 (mylink, windowname) { \t \t \t \t if (! window.focus) return true; \t \t \t var href; \t \t if (typeof (mylink) == 'string') \t \t \t href = mylink; \t \t else \t \t \t href = mylink.href; \t \t my_win = window.open (href, windowname, 'width = 800, height = 1200, scrollbars = yes'); \t \t my_win = window.close(); \t \t} 나는 창문을 열어보십시오. 와이? –

0

제출 버튼이 포함 된 창인 경우 필요합니다. "window.close();" 그렇지 않으면 "var someRef = window.open(); someRef.close()"

-1

PHP를 사용하는 경우이 작업을 수행하십시오. 그것은 나를 위해 작동합니다.

그냥 제출 양식 아래에 배치하십시오. 양식 후 양식 onsubmit 이벤트에서()

echo "<script>window.close();</script>"; 

를 제출하고 window.close를 제거 간다 기능 라인 아래

<?php 
$close = 1; 
if ($close) { 
    echo '<body onunload="self.close()">'; 
} 
0

쓰기

관련 문제