Posted: Wed Mar 16, 2005 9:48 am IE6 Can't load dynamic <script> element's src url
The problem I have is not inserting a script tag on the fly, but to get the src attribute to load the given .js file
Here's what I do:
Code:
IFrameReference = a reference to an iframe
doc = IFrameReference.document
head = doc.getElementsByTagName("head")[0]
var scriptOnFly = doc.createElement('script')
scriptOnFly.type = "text.javascript"
// read somewhere that this will help fire the js file in the src attribute,
// however does not seem to do anything
scriptOnFly.text = "void(0)"
So this appends the <script> element to the <head> element and everything looks great, except for the fact that the <script>'s .js file does not load.
This is the way I need to load the script because it's actually another frame that will insert the <script> element on the fly into the frame I need it in.
Things to know:
1. I test if the script loads by putting an alert in myScript.js
2. I've tried appending the <script> element to the <head> and <body>
3. My script does exist and that is it's url
4. I've done the document.write way but it always overwrites my whole document.
Any suggestions or alternative solutions would be greatly appreciated.
Everything in the above code is fine except for the <script>'s src . The url is correct if it is relative to the site that had the frame that injected the scripts onto the page in the other frame. However the page in the other fram is not from the same site.
All I did was put a full reference to the script http://...
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum