[英]refresh parent page from child's child page
是否可以使用javascript從孩子的子頁面刷新父頁面。
我有一個打開子窗口的Web窗體,子窗口上的按鈕關閉當前子窗口並打開子窗口。 現在,子級上的按鈕應關閉窗口並刷新父級表單。
請建議我這樣做的方式。
謝謝。
對於按鈕單擊事件
父頁面中的代碼
函數fun()
{
window.open('Child.aspx');
return false;
}
子頁面中的代碼
函數fun()
{
window.close();
window.open('SubChild.aspx');
return false;
}
在您的子窗口中使用following。
<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>
最新編輯
在child1.html中編寫一個函數
function child1()
{
opener.document.location.reload(true);
}
如下調用該函數形式child2.html
function child2()
{
window.opener.child1();
}
您是否嘗試過使用這些?
window.opener.reload();
window.opener.location.reload();
我認為window.opener.opener.reload(); 可能工作..
看到您的代碼后進行了編輯。 問題是您要從第一個窗口打開第二個窗口,然后關閉第一個窗口,因此您沒有返回到打開器的參考。 您可以在“父”窗口中調用一個方法來打開第二個窗口,這樣,“父”仍然是您的打開器。
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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.