This is the best solution I've found so far:
At the beginning of each .js file importing another file:
(this file defines a class called 'myclass' and 'km_' is just the prefix I
use for my functions or classes)
----------------------------------------------------------------
// myclass.js
if (typeof(km_scripts) == 'undefined') var km_scripts = new Object();
km_myclass_import('importedfile.js');
function km_myclass_import(jsFile) {
if (km_scripts[jsFile] != null) return;
var scriptElt = document.createElement('script');
scriptElt.type = 'text/javascript';
scriptElt.src = jsFile;
document.getElementsByTagName('head')[0].appendChild(scriptElt);
km_scripts[jsFile] = jsFile; // or whatever value your prefer
}
function km_myclass_alert() {
alert(importedValue);
}
-------------------------------------------------------------
The imported file importedfile.js:
// importedfile.js
var importedValue = 'The file was imported';
----------------------------------------------------------------
The HTML file to test it :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<script language="javascript" src="myclass.js" />
<TITLE></TITLE>
</HEAD>
<BODY>
<input type="button" value="Test!" onclick="km_myclass_alert()" />
</BODY>
</HTML>
Thanx for your helps
Henri
"kaeli" <tiny_one@NOSPAM.comcast.net> a écrit dans le message de
news:MPG.1c07de282427786398a2b0@nntp.lucent.com...[color=blue]
> In article <419e1eb9$0$9105$8fcfb975@news.wanadoo.fr>,[/color]
hmfireball@hotmail.com[color=blue]
> enlightened us with...[color=green]
> > Hi,
> >
> > Is there a way to include a .js file inside a .js file in JavaScript[/color][/color]
1.5?[color=blue][color=green]
> >[/color]
>
> Not that I know of. If you figure one out, I'd love to see it. I'm tired[/color]
of[color=blue]
> having to copy/paste library functions, too.
>
> --
> --
> ~kaeli~
> If a turtle doesn't have a shell, is he homeless or naked?
>
http://www.ipwebdesign.net/wildAtHeart
>
http://www.ipwebdesign.net/kaelisSpace
>
>[/color]