简体   繁体   中英

iframe cross-domain access

I have an HTML page with an iframe included from a cross domain that doesn't belong to me.

I need to do some basic javascript modifications in the iframe (write value and fire up an event -> form processing).

Because of the same origin policy I'm not allowed to do this. However, I need to do it, so I'm searching for a workaround.

The solution is just important that I can run a script for myself. It is enough if it works in one browser and I don't need security for myself.

On my research I have found a lot of ways to break the same origin policy like document.location (in FF only with similar locations), JSONP/sendMessage (I need to be the owner of both domains) and so on, nothing that works with an iframe of a page that doesn't belong to me.

The only "workaround", if you can't make the other site include the relevant CORS headers , would be to fetch the iframe content server side and serve it as coming from your own domain.

The reason there isn't simpler workaround is due to why there is this same origin policy : to protect users.

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