如何在点击提交按钮后关闭我的popupwindow?
我创建了一个popupwindow,可以从我的cakephp中打开我的页面中的一个。 此弹出窗口是链接到其他页面的表单。 一旦你点击'提交'按钮,它会自动保存数据到Mysql并关闭它。如何在点击提交按钮后关闭我的popupwindow?
我想关闭弹出窗口,一旦点击提交按钮。 我设置了top.close();但stil没有功能。
我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>
window.open()返回新窗口的引用。那么你可以:
my_win = window.open(...);
[...]
my_win.close();
function popup(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; my_win = window.open(href,windowname,'width = 800,height = 1200,scrollbars = yes'); \t \t my_win = window.close(); \t \t} 我试着放在window.open后面但是工作。 ÿ? – 2009-11-13 04:14:02
如果弹出窗口是包含提交按钮的窗口,则需要。 “window.close()的;”否则,“var someRef = window.open(); someRef.close()”
如果您正在使用PHP,请执行此操作;这个对我有用。
只需将它放在提交表单下方即可。下面在功能上线
<?php
$close = 1;
if ($close) {
echo '<body onunload="self.close()">';
}
写在那里的形式提交那张之后
echo "<script>window.close();</script>";
和删除window.close()的从表单onsubmit事件
请标记此如JavaScript。 – fserb 2009-11-13 03:22:30