View Full Version : Include Commands In JavaScript
DarkHalf
25-09-1999, 10:07
does any one know how, or if it is done
eg
#include 'js1.js'
function Poo() {
qjkerghdjklafgh
}
so it includes js1.js, like in c
Erm, not having learnt C (yet) I presume you basically want to store sub routines and such in an external (.js) file, and call them from within a page yeah? Like Perl's Require command... C's Include command... and Javascript's... wait a mo, it's done a bit differently in Javascript
http://www.wireplay.co.uk/ubb/smile.gif
When you declare your <SCRIPT> you need to include a SRC for the location of your js file. e.g.:
<SCRIPT SRC="otherscript.js">
(Oh and don't forget the usual language= etc crap too)
This should allow you to call subroutines from otherscript.js without any other commands.
So if you defined a function myfunction() in your js file, then after putting the above header you could just type
function myfunction() {
}
to call it... or whatever.
Erm, it's early... so I've made a mistake somewhere I'm sure... but I presume you'll be able to work it out
http://www.wireplay.co.uk/ubb/smile.gif
Let me know how you get on...
grrrr beat me to it http://www.wireplay.co.uk/ubb/frown.gif
DarkHalf
30-09-1999, 09:38
Unfortunatly, i am doing that, but i wana included em, not have loadsa script tags, dammit http://www.wireplay.co.uk/ubb/smile.gif
i got
<script src="hub.jS" language="JavaScript">
then another of "sub1.js" right next to it, it goes on and on, and these are big scripts. if only my webspace was cgi enabled.
http://www.wireplay.co.uk/ubb/smile.gif
vBulletin® v3.7.4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.