RES: [Javascript] Including additional javascript files
Alex Robinson
latechjavascript at alex.cloudband.com
Mon Apr 4 13:11:04 CDT 2005
>you can do that like this:
>
>function Loadscript(name){
> document.write('<script src="', name, '"
>type="text/JavaScript"><\/script>');
>}
>
>in your page something like:
><script>
>if (red == true) {
> Loadscript("includeRed.js");
>}else{
> Loadscript("includeBlue.js");
>}
></script>
>
>That should work..
Except that it's totally not what I want to achieve. I'm not after
conditionally including the files, I'm after being able to nest the
includes.
I could also insert the scripts by adding extra script elements
through the DOM. But that's also not what I'm trying to achieve.
Actually, now I think of it, seeing that it's really only browsers
that support the DOM that I'm targeting (and providing there's some
graceful fallback for Mac IE5 which doesn't allow adding script
elements), that's a possible solution.
Still doesn't answer my original question though...
More information about the Javascript
mailing list