Marco Calì Marco Calì - 16 days ago 7
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

This works:

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

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