I had two domains for ex. domain1 and domain2, I am opening domain2/index.aspx page as popup from domain1/default.aspx page. While closing domain2 page i need to reload the domain1 page, i had given the javascript code as "Opener.Location.Reload();". I am getting Permission denied javascript error. Any ideas about this issue.
I had two domains for ex. domain1 and domain2, I am opening domain2/index.aspx page as popup from domain1/default.aspx page. While closing domain2 page i need to reload the domain1 page, i had given the javascript code as "Opener.Location.Reload();". I am getting Permission denied javascript error. Any ideas about this issue.
Share Improve this question edited Jul 7, 2020 at 14:15 Martijn Pieters 1.1m320 gold badges4.2k silver badges3.4k bronze badges asked Dec 4, 2008 at 12:01 MarugsMarugs 1- 2 as a minor nit-picky thing, that should be opener.location.reload(); (all lower case) – scunliffe Commented Dec 4, 2008 at 13:18
3 Answers
Reset to default 7I found that setting a parentUrl variable in the popup window (gotten from a query string) and then using :
window.opener.location.href = parentUrl;
works.
I don't know why, I think it's magic, but it works (tested on IE, chrome and Firefox). You cannot read the value of window.opener.location.href, but you can set it to whatever url you want. I use this oddity to do the refresh.
Hope it helps
Certain properties and actions are specifically blocked in cross-domain scenarios. What you might be able to do is create a function on the parent that does the code you want, then call that function from the child.
Example:
// On the parent...
function DoTheRefresh()
{
location.reload();
}
Then, on the child:
opener.DoTheRefresh();
I have done this in the past, so I don't know for sure if it's still an option. I hope it works out for you :)
You can acplish this by putting code in the parent window to detect when the child window has closed.
var win2;
function openWindow()
{
win2 = window.open('http://...','childwindow',...);
checkChild();
}
function checkChild() {
if (win2.closed) {
window.location.reload(true);
} else setTimeout("checkChild()",1);
}