Reputation: 3262
From my child window Im trying to refresh the parent window. I tried several js functions refresh or change the parent window url and non of them gave me what I needed.
alert(window.opener.location.href); //gave null
//all the functions bellow changed the url to
// http://mydomain/www.google.com
window.opener.location.assign("www.google.com");
window.opener.location.replace("www.google.com");
window.opener.location.href = "www.google.com";
window.opener.location = "www.google.com";
I also tried parent.location.href
but didnt change the parent url.
Is there a way I can set the parent url to the desired url? or just let it refresh the page ?Any ideas?
EDIT I cant post sample code because What Im doing is a bit complicated. Im using a salesforce button that calls a new window (asp.net page). I dont have much access to that page other than the .aspx page. Its a compiled version of a project we bought. In the .aspx page Im trying to call a js function because I dont have access to the code behind of that page. My js function is supposed to refresh the parent page once the user press on either (yes or no).
<cc1:ImageButton ID="btnNo" runat="server" OnClick="btnNo_Click"
OnClientClick="pop()" Text="No" Width="40px" />
<script type="text/javascript" language="JavaScript">
function pop(){
window.opener.location.reload(true);
//window.opener.location.href = "www.google.com";
}
</script>
Upvotes: 3
Views: 3806
Reputation: 61812
This should work:
window.opener.location.reload(false);
EDIT
Based on your comments, it sounds like your violating the Same Origin Policy.
Upvotes: 2