0

i create a popupwindow which open 1 of my pages from my cakephp. This popup is a form which link to other page. Upon u click the 'Submit' button, it wil auto save the data to Mysql and close it.

I would like to close the popup window once the click submit button. i set top.close(); but stil no function.

What i mising..

<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>
4

4 回答 4

1

window.open() 返回对新窗口的引用。那么你也能:

my_win = window.open(...);
[...]
my_win.close();
于 2009-11-13T03:22:01.090 回答
0

如果弹出窗口是包含提交按钮的窗口,则需要。“window.close();” 否则,“var someRef=window.open();someRef.close()”

于 2009-11-13T03:30:05.403 回答
0

在提交后表单所在的函数中写下一行

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

并从表单 onsubmit 事件中删除 window.close()

于 2013-05-01T12:50:12.537 回答
-1

如果您使用的是 PHP,请执行此操作;这个对我有用。

只需将其放在提交表单下方即可。

<?php
$close = 1;
if ($close) {
    echo '<body onunload="self.close()">';
} 
于 2011-09-13T01:27:36.127 回答