[Javascript] Function scope question

David T. Lovering dlovering at gazos.com
Tue Oct 7 08:16:24 CDT 2003


I hope I am not missing part of this thread -- some of my email got eaten by my ISP...

About the only sticking point I can see is that you may need to "include" the file with the function definitions into the second file in order to satisfy the function references. I usually put all my "common" JavaScript functions into a single common.js
file, and then include it in BOTH files at the start within the header block.  However, that is only my personal preference and isn't universally necessary.

-- Dave Lovering

Chris Tifer wrote:
> 
> If you included script files like you said in a different e-mail, then I
> don't see any problem with what you've done. Do something very simple just
> to verify.
> 
> In your first file just put:
> 
> function test(){
>     alert("it works")
> }
> 
> In your 2nd file, put:
> 
> test()
> 
> You should see it get called.
> 
> Chris Tifer
> http://micclub.net
> 
> ----- Original Message -----
> From: "Robert Pollard" <rpollard at apple.com>
> To: <Javascript at LaTech.edu>
> Sent: Wednesday, October 01, 2003 6:32 PM
> Subject: [Javascript] Function scope question
> 
> > Hello all,
> >
> > I have 2 files that has several functions that are related.  I needed 2
> > of the functions in one file to be available in the other.  Can you not
> > have a function in 1 file and call it from another file?
> >
> > Thanks,
> >
> > Robert Pollard
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list