none
window.opener.location not working for cross site movement in parent-child windows RRS feed

  • Question

  • Dear Experts,

    I am facing a problem and would appreciate your help. Below is the description:

    I need to open a popup window (http://web2.abc.com/child.aspx)  from my parent window (http://web1.abc.com/parent.aspx )

    After opening child window navigate to another site on different domain (http://www.xyz.com) and return after doing some authentication stuff () to my child page. my child page than check response and form a url string with sone query parameters using variable returned from response. this url is actually belongs to my parent web. child will close its self and parent will be redirected to the new url.

    Parent code ( http://web1.abc.com/parent.aspx ):

    function Popup(url) {
            var newWindow = window.open(url, 'popup','menubar=no,width=1000,height=700,toolbar=no,scrollbars=yes');
            if (window.focus)
              newWindow.focus();
            return false;
    }
    <a href="#" onclick="return Popup('http://web2.abc.com/child.aspx')">Open Popup</a> 

    Child Code (http://web2.abc.com/child.aspx):

    string page = System.Configuration.ConfigurationManager.AppSettings["RedirectURl"];
                    url = page + "type=" + Encrypt(type.ToString()) + "&ID=" + Encrypt(ID.ToString());
    
                    ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Close", "window.opener.location.replace('" + url + "');window.close();", true);

    Now when I run this code on chrome it works fine for me. but on IE it get stucks on child window when return back from (http://www.xyz.com) with below error: 

    "SCRIPT5007: Unable to get value of the property 'location': object is null or undefined"

    I searched on google and found that it is due to cross domain security issue  as IE not able to store opener object when it is redirected to another domain. but could not reached to workable solution. 

    Kindly guide me in this regard. a working example would be great help!

    Regards


    HBkhan

    Monday, February 27, 2017 7:35 AM

All replies