At 2001-05-18 11:55, you wrote:
>At 04:54 18/05/2001, you wrote:
>>You could check if a variable has been declared (one that is declared only
>>in that file)
>
>As far as I know, such a trick is impossible in Javascript. If you try to check a
>variable that hasn't been declared (using "if (myVar)"), you get an error. I haven't
>found a way to be able to do that. If someone has the clue, I would REALLY be
>interested (and we all could, 'cause it would mean auto-importing of different
>packages, in the sense, if a package foo needs a package bar, then when including
>foo, foo says 'I need bar, please auto-include it !'). I have tried to do this for
>the DynAPI, but because of the problem stated above, never managed to do that....
>
>Marc
It's actually quite simple - user-defined global variables/functions are stored in the
window object.
An example:
if(!window.DynAPI) {
}
But the way you want to use this (auto-importing, that is) introduces a whole
different problem though.
Imagine a file A.js that requires B.js and checks if the file already has been loaded
else loads it (with writing a SCRIPT tag) the required file (B.js) is loaded _after_
the current JavaScript-block or file has been executed - not inserted instead of the
SCRIPT tag that was written.
If you can come up with a solution I'll be more than interested!
/Lunna
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev