Click to See Complete Forum and Search --> : Is it possible to include javascript?


cheezsnake
12-01-2003, 11:45 AM
Hello,

I am rather new to javascript. Is there a way to "include" other libraries or classes (other javascripts) in a running javascript? I was hoping there would be a way to use an "include" statement of some kind to call another javascript from the currently running script, but can't find any examples of this. I am not using the javascript for HTML web programming, so I would need an example using pure javascript code. Can anyone help?

Thanks.

Pittimann
12-01-2003, 11:58 AM
Hi!

If I got you right, I can say that it is possible to "include" a script into a script.

Example: you have an external .js file containing pure javascript, let's call it "anotherscript.js".

This will be called in your document:
<script type="text/javascript" id="toBeExchanged" src="anotherscript.js"></script>

In a second script in your document you can change the source, e.g. depending on a function's result:

toBeExchanged.src = "yetanotherscript.js";

Cheers - Pit

cheezsnake
12-01-2003, 01:44 PM
Thanks, Pit.

Please forgive me since I'm new to all this, but the example you listed above looks to be using HTML tags. Will that example work in a javascript that is not web-related? In other words, my javascript has nothing to do with website programming, browsers, or HTML. I'm actually using it to script Photoshop tasks.

Pittimann
12-01-2003, 03:12 PM
Hi cheezsnake!

Sorry! I hadn't realized the necessity of absolutely pure js-code. Of course my example contains an HTML tag. It is the <script> tag itself.

I have done some "pure" js in the past, but if necessary always with html (used locally) implemented.

My post to your thread was useless - sorry once more...

Cheers - Pit