Changing the parent URL of a window from a child that does not change the full URL

From my child window. I am trying to update the parent window. I tried several js functions to update or change the url of the parent window, and they did not give 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.hrefbut did not change the parent URL.

Is there a way to set the parent url to the required url? or just refresh the page? Any ideas?

EDIT I cannot post sample code because what I'm doing is a bit complicated. I use the Salesforce button, which brings up a new window (asp.net page). I do not have much access to this page other than the .aspx page. This is a compiled version of the project that we bought. On the .aspx page, Im trying to call the js function because I don't have access to the code behind this page. My js function should refresh the parent page as soon as the user clicks the button (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>
+3
source share
1 answer

This should work:

window.opener.location.reload(false);

EDIT

Based on your comments, it sounds like you are violating the Same Origin Rule .

+2
source

All Articles