I have an iframe that I dynamically load HTML+JavaScript into. How can I load jQuery into that iframe and get some sort of call back to say it is ready? I can load it in with this code, but there’s no way of telling when it has complete, there must be a better way?
var content = myFrame[0].contentWindow || jqPreviewFrame[0].contentDocument;
var doc = content.document || content;
var head = doc.head;
var jQueryScript = doc.createElement("script");
jQueryScript.type = "text/javascript";
jQueryScript.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js";
head.appendChild(jQueryScript);
Check this question.
Another way which I used in my project is to get jQuery javascript code through
XMLHttpRequest. Pass the URL and wait for itsonreadystatechangeevent. After code arrives successfully useeval()method to execute it. See if it applies to your case too.