是否可以使用javascript从子页面刷新父页面。
我有一个打开一个子窗口的and表单,子窗口上的一个按钮关闭当前的子窗口并打开一个子窗口。现在,子子窗体上的一个按钮应该会关闭窗口并刷新父窗体。
请告诉我做这件事的方法。
谢谢。
对于按钮单击事件
父页面中的代码
函数fun()
{
window.open('Child.aspx');
return false;
}子页面中的代码
函数fun()
{
window.close();
window.open('SubChild.aspx');
return false;
}发布于 2010-04-26 22:30:12
在你的子窗口中使用下面的。
<script type="text/javascript">
function openwindow()
{
opener.document.location.reload(true);
}
</script>编辑过的
创建两个文件1] parent.html
<script type="text/javascript">
function openwindow(url)
{
window.open(url, "mywindow","location=1,status=1,scrollbars=1,resizable=no,width=650,height=650");
}
</script>
<a href="javascript: openwindow('/home/Salil/Desktop/child.html')">Open Child</a>2] child.html
<script type="text/javascript">
function openwindow()
{
opener.document.location.reload(true);
}
</SCRIPT>
<a href="javascript: openwindow()">Refresh Parent</a>最新编辑
在write 1.html中编写一个函数
function child1()
{
opener.document.location.reload(true);
}调用该函数,格式为call 2.html,如下所示
function child2()
{
window.opener.child1();
}发布于 2010-04-26 22:22:10
你试过用这些吗?
window.opener.reload();
window.opener.location.reload();
我认为window.opener.opener.reload();可能行得通..
发布于 2010-04-26 22:22:31
在看到您的代码后进行编辑。问题是你从第一个窗口打开第二个窗口,然后关闭第一个窗口,这样你就不能再参考打开的窗口了。你可以在你的父窗口中调用一个方法来打开第二个窗口,这样父窗口仍然是你的开启器。
Parent.html
function openWindow(sURL){
window.open(sURL);
}Child1.html
function fun(){
window.opener.openWindow('Child2.html');
window.close();
}Child2.html
function fun(){
window.opener.location.reload(true);
}https://stackoverflow.com/questions/2714123
复制相似问题