Marco Calì Marco Calì - 10 months ago 73
Javascript Question

Trigger Custom Event From Iframe To Parent Document

I am having some trouble to fire a custom event inside an iframe and detect it from the parent document.
Both iframe and parent document have the same source (same protocol, same host, same port).

Any advises?

Answer Source

This works:

parent.$('body').trigger('eventName');

the event triggered inside the iframe will be detected in the parent document.