[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3468
  • Last Modified:

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

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?
0
cpaino
Asked:
cpaino
  • 2
1 Solution
 
nabsolCommented:
Hi

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

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


By Nab
0
 
cpainoAuthor Commented:
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.
0
 
cpainoAuthor Commented:
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?!
0
 
GranModCommented:
PAQed with points refunded (200)

GranMod
Community Support Moderator
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

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