Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
同じドメインの2 つの iframe ( iframe1とiframe2 ) があり、これらは別のドメインのドキュメントでホストされています。postMessage()を介して通信できるように、iframe2からiframe1を参照するにはどうすればよいですか。
私は自分で答えますpostMessage()。iframe とその親ドキュメントの間の通信に理想的です。sessionStorageしかし、私の場合は、同じオリジンからの iframe 間の通信 に使用する方が良いでしょう。
postMessage()
sessionStorage
https://developer.mozilla.org/en/DOM/Storage
HTML5 の postMessage メソッドの説明と使用例は、十分に文書化されています。jQuery を使用している場合は、必要なコードの多くを抽象化する次のプラグインも非常に便利です。