In the parent window, I have this script
function injectJS() {
var myIframe = document.getElementById("MyFrame");
var script = myIframe.contentWindow.document.createElement("script");
script.type = "text/javascript";
script.src = "/myscript.js";
myIframe.contentWindow.document.body.appendChild(script);
}
then for my iframe, I have
<iframe id="MyFrame" onload="injectJS()"></iframe>
As I inspect the iframe element, I see the script tag has been inserted with it's source being the script I wanted /myscript.js. So everything appears to be working however the script is not working. Nothing is wrong with the script as it works fine everywhere else. What could be causing it to not work in the iframe even though the script tag was successfully injected and links to the script I want loaded.