[Javascript] Reaching out to external JS file.

Andrew Gibson andyg at ihug.co.nz
Sun Oct 5 15:29:29 CDT 2003


Yes. Perhaps you can't reference an external script this way, using
document.write
When the page loads I think it might load all the references first....so
using document.write probably wont work.....

If you want to dynamically create a src link, you can change it later
directly in Javascript, well at least I know you can in IE.....
Something like    document.getElementById("myscript").src="myscript.js"

Andrew Gibson

> If your sxripts and files reside in the same level domain, relative links
> shoud work, but I'm not sure, what you're trying to achieve here?!
>
> And don't forget, you are overwriting the page that holds the
script-caller,
> 'myscript' instantly as the page loads, and this page does't exist
anymore,
> there is no way you can reference to it again, because the name and the
> address  are in another format now ...folder_myScript.js orsomething like
> it. This, that, the script myscript is unreachable if you have overwritten
> the page once.
>
> Think it over
>

> >Hi!
> >I am importing a myscript.js file within a file. I use:
> ><csscriptdict import>
> ><script type="text/javascript" src="../myscript.js "></script>
> ></csscriptdict>
> >
> >This script references another file like this:
> >document.write("<link href='IE.css' rel='stylesheet' media='screen'>")
> >
> >Unfortunately this myscript.js file is to be called from other pages
within
> >the site and their hierarchy levels differ.
> >
> >Is it possible to make sure the links are right?
> >I tried putting direct URLs for the src and href, but it does not seem to
> >work better.
> >




More information about the Javascript mailing list