[Javascript] Function scope question
Robert Pollard
rpollard at apple.com
Tue Oct 7 18:31:46 CDT 2003
So if I understand you correctly, the HTML is what loads the JavaScript
files. You can't load a JavaScript file from within another JavaScript
file?
Thanks,
Robert
On Tuesday, October 7, 2003, at 04:07 PM, BEKIM BACAJ wrote:
> I thik the cauleage, is says that you can split the script in two
> files, (exactly *.js files) than call the from any page you like
>
> first JS file :
> container.js
> [content]
> function AreYouThere(){
> alert('\"I\'m here\"')
> }
>
> second JS file :
> [content]
>
> document.onclick=AreYouThere
>
> Any HTML page
>
> script tags
>
> add src="theAddress/container.js"
>
> the other script tag src = "theAddress/caller.js"
>
> If you click the page you will recieve the alert box saying "I'm Here"
>
>> From: Robert Pollard <rpollard at apple.com>
>> Reply-To: "[JavaScript List]" <javascript at LaTech.edu>
>> To: "[JavaScript List]" <javascript at LaTech.edu>
>> Subject: Re: [Javascript] Function scope question
>> Date: Tue, 7 Oct 2003 08:16:12 -0700
>>
>> Hello Dave,
>>
>> Would you mind sending an example of what you are talking about? How
>> do you "include the file with function definitions into the second
>> file?" I don't believe I've seen this syntax. What's interesting is
>> one file can see a function from the other but not the other way
>> around. Maybe it's syntax and the error is seeing the function but
>> something else is causing problems.
>>
>> Thanks for the response,
>>
>> Robert
>>
>> On Tuesday, October 7, 2003, at 06:16 AM, David T. Lovering wrote:
>>
>>> 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
>>> _______________________________________________
>>> 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
>
> _________________________________________________________________
> Add photos to your messages with MSN 8. Get 2 months FREE*.
> http://join.msn.com/?page=features/featuredemail
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list