Appending Script Tag Through Javascript In Dom And Setting Its Src Throws Error
I am trying to append script tag through JS and set its src. Following is the code: var myscript = document.createElement('script'); myscript.setAttribute('src', 'http://player.ooy
Solution 1:
IE7 doesn't give error when player.js loads with page but it does when loaded dynamically. Besides if you ignore the error and let the script works, player appears normally. If you insist on to remove error, you can create an iframe and load a player.html page inside it so that you can run your player.js when page loads without error.
<html><head><scripttype="text/javascript">functioncreateIframe (iframeName, width, height) {
var iframe;
if (document.createElement && (iframe = document.createElement('iframe'))) {
iframe.name = iframe.id = iframeName;
iframe.width = width;
iframe.height = height;
iframe.frameBorder = "0";
iframe.style.border = "none";
iframe.src = 'about:blank';
document.body.appendChild(iframe);
}
return iframe;
}
functionload_item() {
var iframe = createIframe ('iframe0', 320, 240);
if (iframe) {
iframe.src = "player.html";
}
}
</script></head><body><aonclick="load_item();">click to load</a></body></html>
Here is player.html:
<html><bodystyle="margin: 0px; padding: 0px;"><scriptsrc="http://player.ooyala.com/player.js?........."></script></body></html>
Post a Comment for "Appending Script Tag Through Javascript In Dom And Setting Its Src Throws Error"