Kunj
Kunj

Reputation: 2018

Custom event not listened by parent window from iframe

I want to listen a custom event triggered from the iframe in parent window. I tried to bind event even on document and window but not succeed.

Main JS:

$(document).bind('EVENT_ANIMATION_COMPLETE', onAnimationComplete);

JS using in iframe:

$(document).trigger('EVENT_ANIMATION_COMPLETE');

Upvotes: 0

Views: 346

Answers (1)

epascarello
epascarello

Reputation: 207527

Because the document in the iframe is not equal to the document in the parent.

There are a couple of ways to do it, one way is

parent.$(parent.document).trigger("EVENT_ANIMATION_COMPLETE");

Upvotes: 2

Related Questions