[Javascript] How to call scripts that are all in one file...?

Rick Holcomb rholcomb at holc.biz
Fri Feb 3 20:43:27 CST 2006


You could wrap each file in a function and then call the function when
needed. 

Contents of myscripts.js:

Function routine1{
	//Insert all code from the myroutine1.js file
}
Function routine2{
	//Insert all code from the myroutine2.js file
}
Function routine3{
	//Insert all code from the myroutine3.js file
}
Function routine4{
	//Insert all code from the myroutine4.js file
}

In your html document:

<script type="text/javascript" src="javascripts/myscripts.js"></script>

Put these lines in the proper place in your html file:

<script type="text/javascript">
	routine1;
</script>

<script type="text/javascript">
	routine2;
</script>

<script type="text/javascript">
	routine3;
</script>

<script type="text/javascript">
	routine4;
</script>


Rick

-----Original Message-----
From: javascript-bounces at LaTech.edu [mailto:javascript-bounces at LaTech.edu]
On Behalf Of Jonathan Gold
Sent: Friday, February 03, 2006 9:16 PM
To: [JavaScript List]
Subject: Re: [Javascript] How to call scripts that are all in one file...?

I guess I wasn't clear; sorry. They are presently each in their own
file in a folder called 'javascripts' and I call them, now, like this:

<script type="text/javascript" src="javascripts/myRoutine1.js"></script>

And, then further down the html file, I call another:

<script type="text/javascript" src="javascripts/myRoutine2.js"></script>

And then, still further:

<script type="text/javascript" src="javascripts/myFunction1.js"></script>

What I would like to do is have them all be in _one_ file inside the
'javascripts' folder; say a file called 'myScripts.js'. When I try to
do this now, I do not know how to separate the different functions and
routines in that myScripts.js file. When I call the whole file by
name,

<script type="text/javascript" src="javascripts/myScripts.js"></script>,

all the scripts run. How do I call them one at a time?

My intuitve approach was to call a single one like this:

<script type="text/javascript"
src="javascripts/myScripts.js/myFunction1()"></script>

but that didn't cut it.

Thanks.

On 2/3/06, Troy III Ajnej <trojani2000 at hotmail.com> wrote:
> Supposedly that you are not throwing a joke on us, I believe you should
call
> them, -individual functions, by their names. As you would call, John,
Paul,
> George, Ringo individualy from the group/band. Obviously you can not call
> the Beatles in order to get a real response since there is no such call
> implemented and functional even in real life. But you can introduce them
to
> the HTML show as Beatles.js and then you can call them by names as the
event
> takes place: onLightsOff="Ringo(drums)", etc.
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Troy III
> progressive art enterprise
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>

--
Jonathan
Berkeley, CA
http://home.pacbell.net/jonnygee/





More information about the Javascript mailing list