简体   繁体   中英

Passing messages from iframe to parent window (cross-domain)

I need to pass a message from an iframe to the parent window. The parent window and iframe window are from different domains so I am running into difficulty with same origin restrictions (ie, my attempts to access window.parent from the iframe are blocked).

I have been able to pass messages from the parent window to the iframe using the window.location.hash method as described in this article . However, the method does not appear to work for sending messages from the iframe to the parent window.

I must also find a solution that works in IE7 and IE8.

Does anyone know how to do this?

I'm about to give up and build a web API to facilitate messages from the iframe to the parent window.

Take closer look at window.postMessage API. It allows you to send message across all domains and between iframes. Perfectly works on IE as well

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