最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin4浏览0评论

I have two web application on different domain.

  1. Web App1
  2. Web App2

My Final goal is as par below.

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

By using same concept I am trying to do below things

  1. Open WebApp2 from WebApp1

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

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

  4. 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 wele.

I have two web application on different domain.

  1. Web App1
  2. Web App2

My Final goal is as par below.

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

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

By using same concept I am trying to do below things

  1. Open WebApp2 from WebApp1

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

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

  4. 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 wele.

Share Improve this question edited Dec 16, 2019 at 3:03 sideshowbarker 88.4k29 gold badges215 silver badges212 bronze badges asked Aug 13, 2018 at 8:05 DeveloperSDDeveloperSD 3162 gold badges3 silver badges22 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 0

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论