In javascript, I am inserting a <script tag>
into an iframe like this:
var iframe = document.getElementById('iframe');
var doc= iframe.contentWindow.document.getElementsByTagName('head')[0];
var jquery = document.createElement("script");
jquery.type = "text/javascript";
jquery.src = "jquery-1.9.1.min.js";
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "blah.js";
doc.appendChild(jquery);
doc.appendChild(script);
However, there is jquery code in the blah.js
, and sometimes this script fails because the jquery script didn't finish loading yet. Is there a way to wait until it finished loading?
Thanks.