Cross Origin Communication – window.postMessage

The Window.postMessage helps to make scripts talk over different domain connections. When you call a function on an external iframe from the parent window, Javascript won’t allow it. That’s because of the Cross Domain Policy that makes this not possible. But it’s possible since Javascript introduced postMessage function. Suppose you want to call a function on an cross domain iframe with id monu. Let the function be subins(). Here’s how to do it using postMessage technic.