admin管理员组

文章数量:1331849

I have an HTML and an iframe inside it. when I try to access iframe contents it shows error like this.

" Uncaught DOMException: Blocked a frame with origin "" from accessing a cross-origin frame.
    at .html:14:24
(anonymous) @ test.html:14 "

how some chat panies like "inter" and etc, accessing iframe from external server and ponents inside iframe..?

I have an HTML and an iframe inside it. when I try to access iframe contents it shows error like this.

" Uncaught DOMException: Blocked a frame with origin "http://parattapayyan.surge.sh" from accessing a cross-origin frame.
    at http://parattapayyan.surge.sh/test.html:14:24
(anonymous) @ test.html:14 "

how some chat panies like "inter" and etc, accessing iframe from external server and ponents inside iframe..?

Share Improve this question edited Dec 30, 2017 at 8:11 P.Thangamageswari 485 bronze badges asked Dec 30, 2017 at 7:12 Sanoj SenSanoj Sen 171 gold badge1 silver badge3 bronze badges 1
  • 2 Possible duplicate of SecurityError: Blocked a frame with origin from accessing a cross-origin frame – Deepak Keynes Commented Dec 30, 2017 at 7:25
Add a ment  | 

1 Answer 1

Reset to default 1

When Site A tries to fetch content from Site B in a frame, by default, Site B's pages are not accessible due to security reasons(Read this :: https://developer.mozilla/en-US/docs/Web/Security/Same-origin_policy); But using the Access-Control-Allow-Origin header site B can give cross-origin access to specific requesting origins.

Site B can serve its pages to Site A with the following response header:

Access-Control-Allow-Origin: http://www.siteA.

Without site B doing this, you won’t be able to access site A in a frame.

本文标签: javascriptAccessing Iframe Cross OriginStack Overflow