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