简体   繁体   中英

Javascript: communications between frames

I have two different applications loaded into different frames. I need them to communicate I know that javascript security model does not allow frames loaded from different domains to communicate but since I control both applications maybe there is a way to allow frames loaded from specific another domain to communicate with this frame

If it is not possible what's the hack around? Apps are different and I need to load them at different domains (or at least different ports) I can not run them as one app

If they share top-level domain (eg foo.example.com and bar.example.com ), then you can set document.domain = 'example.com'; to relax same-origin restriction .

If you support only HTML5 browsers, then there's postMessage() exactly for cross-domain communication.

Other options are JSONP (fancy name for a cross-domain <script> tag) and proxying of XmlHttpRequest via the server on each domain.

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