Reputation: 28174
I have a page embedded in a parent page via an iframe (same domain). jQuery is loaded in the iframed page, not in the parent page.
From within an iframe, I can use $(document).ready to know when the document is ready. But how can the iframed page know when the parent document is ready?
Upvotes: 1
Views: 2975
Reputation: 95055
Test the readyState
property of top.document
or parent.document
. Using $(...).ready
will actually listen for the ready event of the iframe, not what you pass into it.
Ref: https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L254 (Notice how it never actually uses this
, it just returns it for chainability)
For an example of how to actually listen for the event to happen or test if it has already happened, i'd suggest looking at how jQuery does it. https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L870 (replacing document
with top.document
where appropriate)
Upvotes: 4