Is it possible to refresh parent page from child's child page using javascript.
I have a webform which opens a child window, a button on child window closes the present child window and opens a subchild window. Now a button on subchild should close the window and refresh the parent form.
Please suggest me the way of doing it.
Thank You.
For button click event
Code in Parent Page
function fun()
开发者_如何学Python{
window.open('Child.aspx');
return false;
}
Code in child page
function fun()
{
window.close();
window.open('SubChild.aspx');
return false;
}
Use following in your child window.
<script type="text/javascript">
function openwindow()
{
opener.document.location.reload(true);
}
</script>
EDITED
create two files 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>
EDITED LATEST
write a function in child1.html
function child1()
{
opener.document.location.reload(true);
}
call that function form child2.html as follows
function child2()
{
window.opener.child1();
}
Have you tried using these?
window.opener.reload();
window.opener.location.reload();
I think window.opener.opener.reload(); may work..
EDITED after seeing your code. The problem is you're opening the 2nd window from the 1st window and closing the 1st window so you have no reference back to the opener. You can instead call a method in your Parent window to open the 2nd window, that way the Parent is still your opener.
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);
}
精彩评论