简体   繁体   中英

how to solve iframe's cross-origin issue?

Usually getting access to elements from iframe will cause cross-origin error:

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

There are plenty of methods to solve it by building up communications between parent page and iframe page.

However in my case, iframe's src is an published website, which means I can not modify it or control it.

How can I solve this kind of cross-origin issue???

ok so you are trying to access components on iframe. If this is only working a demo/trial tool you can disable websecurity. Some hints here.

Uncaught DOMException: Blocked a frame with origin "http://localhost:8080" from accessing a cross-origin frame while listing the iframes in page

Dirty solution:

for windows:

chrome.exe --user-data-dir="" --disable-web-security for mac:

open -a Google\\ Chrome --args --disable-web-security --user-data-dir="" In this way you open the chrome and let it ignore the web security.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM