popup window reload parent.window.opener caused permission denied error if opener window navigate to other page

Posted on 2006-04-17
Last Modified: 2012-06-27
Hi, I have following JS problem can't be fixed. Hope somebody can help me here.
I have a linke in window A, when click open a popup window B, there is close button in B, after user finish their work in B, they click "close" button, it should close popup and refresh the calling window A. See following code I did:

<a href="javascript:top.close();parent.window.opener.location.reload();"><img align="top" src="../../images/button_blue_close<%=session("version")%>.gif" valign="center" border="0"></a>

I used "parent.window.opener" here since window A is inside a frameset, there is a menu bar above A. If user navigate in calling window such as click menu in to change content from A to C. then popup B close button will give me "permission denied" error. If they keep A window not change, then everything works fine.  I know the error caused by" parent.window.opener.location.reload();" since the url already changed. But I have to refresh the calling window to show update information there and I can't control people don't do navigation in calling page. Is there any suggestion here?
Question by:cpaino
    LVL 6

    Expert Comment


    Hope that you can get some idea and this is what you want. Need anything else let me know.

    <title>Form Example</title>
    <script LANGUAGE="JavaScript" type="text/javascript">
    var DispWin;
    function display() {
      DispWin ='','NewWin', 'toolbar=no,status=no,width=300,height=200')
      message = "<head><script language='JavaScript'>"
      message += "function a(){\n"
      message +=  ";\n"
      message +=  "window.close();\n"
      message += "}\n"
      message += "<\/script></head> <body>"
      message += "<ul><li><b>NAME: </b>" + document.form1.yourname.value;
      message += "<li><b>ADDRESS: </b>" + document.form1.address.value;
      message += "<li><b>PHONE: </b>" + + "</ul><br>";
      message += "<input type='button' value='Close' onclick='a()'></body>";
    function test()
    <h1>Form Example</h1>
    <form name="form1">
    <p><b>Name:</b> <input TYPE="TEXT" SIZE="20" NAME="yourname">
    <p><b>Address:</b> <input TYPE="TEXT" SIZE="30" NAME="address">
    <p><b>Phone: </b> <input TYPE="TEXT" SIZE="15" NAME="phone">
    <p><a href="javascript:display()">GO</a></p>
    <p><input TYPE="BUTTON" VALUE="check" name="check" onClick="test();" style="display:none"></p>

    By Nab

    Author Comment

    Nab, Sorry I may not clear with my question. I tried yours, it doesn't solve my problem. My calling page is A which is in a frameset, it has a link to popup window B, when user close window B, it will refresh the window A. But window A may open popup B, then A switch to C inside frameset based on user click on the menu. now user try to close popup window B back to A, A is no more there. get permission denied error.

    Author Comment

    I got a solution for my problem from my co-worker George. Following is his solution:
    window A popup window B, in B, use "top.close();" to close B. In A, <body onfocus="self.location.reload();">
    Then I don't need to worry about refresh of window A, whenever A is on focus, it will reload to show update data there. Is that a neat and simple one?!

    Accepted Solution

    PAQed with points refunded (200)

    Community Support Moderator

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
    Article by: DanRollins
    This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (, we'll extend the program by adding a depth-…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now