[Javascript] Including one javascript file within another

Flavio Gomes flavio at economisa.com.br
Thu Oct 13 07:52:21 CDT 2005


Or create an invisible iframe and read it's contents or try XMLHTTP 
functions.

But I'd go for the server side include though.

-- 
Flavio Gomes
flavio at economisa.com.br


Julien Nadeau wrote:

> 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 <mailto: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 <mailto:Javascript at LaTech.edu>
>> https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>>
>>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>  
>



More information about the Javascript mailing list