• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2798
  • Last Modified:

How to refresh parent page in javascript client-side code?

The below client-side javascript is not refreshing my parent page?  Do you have any ideas what I can do?
I am executing inside the if statement.  I am just not refreshing the parent page.  The code closes the child page, and refreshes the current page.  It does  not redirect to the newly assigned page.

It does not know recognize the parent.window.opener object.  I can see that it is open though.

<script language="javascript">
function refreshPage(inpRedirectURL){       
      alert("inside refreshPage" + inpRedirectURL);
      try {      

        if (parent.window.opener && !parent.window.opener.closed) {      
               //parent.window.opener.href = inpRedirectURL;
               parent.window.opener.href = "search/searchmain.asp?";
                              parent.window.opener.location.reload();
                                            //alert("Refreshing Page");
                                            window.self.close();  
    }
  } catch (e) {
    //alert('Error on parent window!');
  }
}
</Script>
0
swansonplace
Asked:
swansonplace
  • 4
1 Solution
 
basicinstinctCommented:
this line:

parent.window.opener.href = "search/searchmain.asp?";

should be this:

parent.window.opener.location.href = "search/searchmain.asp?";
0
 
basicinstinctCommented:
and you don't need this line:

parent.window.opener.location.reload();

just changing the location.href will load the page anyway... if you call the reload immediately you will ruin what you are trying to do as the new url won;t have loaded yet so it will reload the old url...
0
 
basicinstinctCommented:
just pointing out that the syntax you are using suggests that your code is being executed in a frame inside a page that was opened as a popup (using the window.open function).
0
 
basicinstinctCommented:
if it's not inside a frame then you can lose the "parent." everywhere, for example:

parent.window.opener

becomes

window.opener
0
 
swansonplaceAuthor Commented:
Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now