添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

DOMException: Blocked a frame with origin "http://localhost" from accessing a cross-origin frame

Ask Question

I have found the tutorial to login with Google account API in Asp.net MVC - 5.

https://tutorialslink.com/Articles/How-to-login-with-Google-account-API-in-Aspnet-MVC---5/18

By using same concept I am trying to do below things

  • Open WebApp2 from WebApp1

  • From WebApp2 on Apply event redirect to specified URL consist of URL + required data in encrypted format.

  • From WebApp1 by continuously checking for the updated URL and accordingly display the data on WebAp1.

  • Close the WebApp2.
  • To achieve the above steps, my source code (WebApp1) as par below.

    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);
    

    I am getting below error at code line

    [if (webApp2.document.URL.indexOf(REDIRECT) != -1) {]
      

    DOMException: Blocked a frame with origin "http://localhost" from accessing a cross-origin frame.

    Please any one can guide me to resolve above error.

    I have tried with enabling CORS in WebApp2 but it didn't work.

    Any idea to design WebApp2 is highly welcome.

    I have got the work around for the same.

    In my WebApp2 After finishing with processing I am redirect control to my WebApp1 i.e to domain1.

    Reference:

    How do I get around window.opener cross-domain security

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.