Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
109
rated 0 times [  115] [ 6]  / answers: 1 / hits: 17582  / 11 Years ago, wed, september 25, 2013, 12:00:00

I'm working through Third Party Javascript. I'm particularly interested in communication between a parent page and a child frame from a different origin. Using window.postMessage, it's trivial to safely send messages from the child and have the parent receive them with the message event.



I have had no luck going the other direction. Can I get some confirmation that it is not possible to communicate from the parent to the child using postMessage? If not what are ways of working around this problem?


More From » html

 Answers
5

You should be able to use .postMessage() between any two cooperating windows. It doesn't matter which direction you are sending the message. If it is not working in one direction, then there is probably an error in the implementation. You may need to make sure you have the proper window object.



For an iframe, you would want to use the .contentWindow property to get its window in modern browsers.



Some good documentation here: https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage


[#75432] Tuesday, September 24, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bryantc

Total Points: 455
Total Questions: 96
Total Answers: 110

Location: San Marino
Member since Thu, Jun 30, 2022
2 Years ago
bryantc questions
Fri, Aug 13, 21, 00:00, 3 Years ago
Tue, Mar 30, 21, 00:00, 3 Years ago
Fri, Jun 5, 20, 00:00, 4 Years ago
Wed, May 27, 20, 00:00, 4 Years ago
;