Forum Moderators: open
<script language="JavaScript" src="scripts/file1.js"></script>
<script language="JavaScript" src="scripts/file2.js"></script>
If you define a variable, function or whatever in file1.js, you can call your function, or reference your variable from code in file2.js
Shawn
Two things come to mind:
First, the obvious - load two (or more) .js files with the document and code from one file can reference code in the other file.
But both files must be linked to the document.
More in line with what I think you're looking to do is to link to a scripted page which returns javascript and can contain an include just like any other scripted page.
Details:
<script type="text/javascript" src="mainscript.asp"></script>
In the mainscript.asp page you set the response.contenttype to "text/javascript" so that it returns data with the proper type.
From there on in, you can include code to your heart's content just like any other asp page. It's just got to be valid, working javascript.
This can be done with any sophisticated server-side scripting engine. PHP for sure.
includefile = 'somefile determined dynamically';
document.write('<script type='text/javascript src="'+includefile+'"></script>');
nasty - I've used this on IE 5.5 only - not sure if it will work on other browsers.