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" <ti******@NOSPAM.comcast.net> a écrit dans le message de
news:MP************************@nntp.lucent.com...
In article <41**********************@news.wanadoo.fr>,
hm********@hotmail.com enlightened us with... Hi,
Is there a way to include a .js file inside a .js file in JavaScript
1.5?
Not that I know of. If you figure one out, I'd love to see it. I'm tired
of 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