I create an iframe dynamically to use as a place to do a form based API call.
$('<iframe>').attr({
name : "secret_sending_iframe",
src : "#",
style : "visibility:hidden; width:0px; height:0px;"
}).appendTo("#recordingControl");
this has the side effect of causing my $(document).ready() to fire again. This is understandable as it’s telling me that my iframe is ready, but now I need to distinguish the initial document ready from this new document ready. Is there some way to tell that it’s the iframe that just became ready other than testing for the negative existence of the iframe to tell that it’s the first call to .ready()?
BTW – testing for $(“iframe”) in the $(document).ready() call returned [] which I did not expect. So the best solution for me was to use the window.location.href, see below…
Each frame has it’s own separate javascript context and it’s own separate
$(document).ready(). So, I don’t think you’re seeing the same$(document).ready()get called more than once unless you have multiple calls to$(document).ready()in the same document. Otherwise, each time it would be called would be a different document.If you have identical code and you need to know which one is being called, you can always look at the
window.locationobject to see what page/frame you’re in. To understand your situation, I’d suggest adding this to each one:And, then you can separate out which is which.