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

Cutter java.script at seacrets.com
Fri Feb 3 20:55:34 CST 2006


Jonathan,

Sounds like you need to learn a little about functions and how they're 
written. JS written within an external file, and called in the fashion 
you described, would run in the same basic manner as it would if it sat 
between a pair of <script> tags on your page.

    <!--\\ This code would pop up a message as soon
   // as the browser began to parse it, whether within
   // a pair of tags or from an externally linked .js file
    var myVar = "Hello World";
    alert(myVar);

    <!--\\ This code would have to be called by it's
    // name before it would execute
    function callMe(){
        var myVar = '867-5309';
        alert(myVar);
    }

    <!-- and later in your html -->
    <a href="javascript:void(0);" onclick="callMe();">Call Me</a>

Hope this helps you as you review the four files of js that you have.

Cutter

If the following code

Jonathan Gold wrote:
> 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/
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>   



More information about the Javascript mailing list