title: DOMException: Blocked a frame with origin "http://localhost" from accessing a cross-origin frame
body: <p>I have two web application on different domain.</p>
  
  <ol>
  <li>Web App1 </li>
  <li>Web App2 </li>
  </ol>
  
  <p>My Final goal is as par below.</p>
  
  <p><a href="https://i.stack.imgur.com/xClqc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xClqc.png" alt="enter image description here"></a></p>
  
  <p>I have found the tutorial to login with Google account API in Asp.net MVC - 5.</p>
  
  <p><a href="https://tutorialslink.com/Articles/How-to-login-with-Google-account-API-in-Aspnet-MVC---5/18" rel="nofollow noreferrer">https://tutorialslink.com/Articles/How-to-login-with-Google-account-API-in-Aspnet-MVC---5/18</a></p>
  
  <p>By using same concept I am trying to do below things</p>
  
  <ol>
  <li><p>Open WebApp2 from WebApp1 </p></li>
  <li><p>From WebApp2 on Apply event redirect to specified URL consist of URL + required data in encrypted format.</p></li>
  <li><p>From WebApp1 by continuously checking for the updated URL and accordingly display the data on WebAp1.</p></li>
  <li>Close the WebApp2.</li>
  </ol>
  
  <p>To achieve the above steps, my source code (WebApp1) as par below.</p>
  
  <pre><code>var REDIRECT = "http://localhost/Home/Test";
  var webApp2 = window.open("WebApp2Url", "CrossDomain", '', true);
  
  var pollTimer = window.setInterval(function () {
  try {
      if (webApp2.document.URL.indexOf(REDIRECT) != -1) {
      window.clearInterval(pollTimer);
      // logic to retrieve data from webApp2.document.URL
      webApp2.close();
      debugger;
      }
  }
  catch (e) {
  }
  }, 500);
  </code></pre>
  
  <p>I am getting below error at code line </p>
  
  <pre><code>[if (webApp2.document.URL.indexOf(REDIRECT) != -1) {]
  </code></pre>
  
  <blockquote>
    <p>DOMException: Blocked a frame with origin "<a href="http://localhost" rel="nofollow noreferrer">http://localhost</a>" from
    accessing a cross-origin frame.</p>
  </blockquote>
  
  <p>Please any one can guide me to resolve above error.</p>
  
  <p>I have tried with enabling CORS in WebApp2 but it didn't work.</p>
  
  <p>Any idea to design WebApp2 is highly welcome.</p>