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_scri pts) == 'undefined') var km_scripts = new Object();
km_myclass_impo rt('importedfil e.js');
function km_myclass_impo rt(jsFile) {
if (km_scripts[jsFile] != null) return;
var scriptElt = document.create Element('script ');
scriptElt.type = 'text/javascript';
scriptElt.src = jsFile;
document.getEle mentsByTagName( 'head')[0].appendChild(sc riptElt);
km_scripts[jsFile] = jsFile; // or whatever value your prefer
}
function km_myclass_aler t() {
alert(importedV alue);
}
-------------------------------------------------------------
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="javas cript" src="myclass.js " />
<TITLE></TITLE>
</HEAD>
<BODY>
<input type="button" value="Test!" onclick="km_myc lass_alert()" />
</BODY>
</HTML>
Thanx for your helps
Henri
"kaeli" <ti******@NOSPA M.comcast.net> a écrit dans le message de
news:MP******** *************** *@nntp.lucent.c om...
In article <41************ **********@news .wanadoo.fr>,
hm********@hotm ail.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