[Javascript] Including one javascript file within another

Julien Nadeau junado at junado.com
Wed Oct 12 13:10:16 CDT 2005


There's 2 ways to do it.

The first one, which is probably the best one since you seem to have  
server scripting, is to use an "include" statement in the scripting  
language available to you (php or asp).

The other way would be to split your files in two, and use three  
<script language="JavaScript" type="text/javascript" src="filepath">  
to include your first path, then your modified file, then the last  
part of your script.

Julien Nadeau
junado at junado.com

Le 05-10-12 à 13:56, Rick Holcomb a écrit :

> I have a script file that I want to use as a variable script (will be
> changed by the server).
> I want to include that file in another javascript file.
> The included file really only contains the definition of a variable.
> How can I do this.
>
> Contents of mainfile.js:
>
> <!-- Begin
> var swidth=270
> var sheight=20
> var sspeed=6
> var wholemessage=''
>
> <!-- include include.js here
> <!-- this include defines the mainmessage variable
>
> var wholemessage='<div>' + mainmessage </div>'
>
> <!-- End
>
>
> Contents of include.js
> <!-- Begin
> var mainmessage = 'main message goes here!'
> <!-- End
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20051012/bafe5942/attachment.htm>


More information about the Javascript mailing list