Forum Moderators: open
If I write a javascript file include line such as "<script src='/myjsfile.js'></script>" using document.writeln() will the browser actually go and fetch the file?
Sort of a dynamic way to include script files.
Another way to acheive (and there are others, too) the same result is to hard-code the script tag change the src attribute using javascript. The browser should dynamically load the js file and apply to document.
I have it working in a sample page. I will apply it to the application I have.
Thanks again. Much appreciated. :)
I was using the document.write() to write the entire document contents to the page. Sounds silly, but there was a reason. It still didn't work properly no matter what sort of method I followed. What I had working earlier was a test, but the actual document still ****ed when something in the body tries to reference a function or object I had in one of those included javascript files.
The solution was to write the head and body of the document with different document.write() calls and separate them with a closing </script> tag.
Kinda like:
<script>
document.write("The entire head");
</script>
<script>
document.write("Stuff in the body");
</script>
So it works, just have to separate them out. I noticed this about IE a while back. It's a kind of flush it seems. NS7 and Opera seemed fairly ok, but had a few niggles, but they should work correctly now.