Connecting Tech Pros Worldwide Forums | Help | Site Map

Load an External Javascript Function

Newbie
 
Join Date: Aug 2007
Posts: 13
#1: Aug 29 '07
Hi

I have a javascript file called external1.js . This file has a function say function1.
In the function I need to make a call to external2 javscipt file(external2.js) function.

the sample code is
external1.js
Expand|Select|Wrap|Line Numbers
  1. function1
  2. {
  3.  .........
  4. function2()// this function is defined in external2.js
  5. .................
  6. }
external2.js
Expand|Select|Wrap|Line Numbers
  1. function2
  2. {
  3. ................
  4. ................
  5. .................
  6. }
How do i achieve this functionality

Thank u
Mansoor.

markrawlingson's Avatar
Moderator
 
Join Date: Aug 2007
Location: Bowmanville, Ontario
Posts: 329
#2: Aug 29 '07

re: Load an External Javascript Function


Although I'm not a fan of having any more than 1 external stylesheet or javascript file, you could Include both external references on your page(s) to obtain the desired effect.

Sincerely,
Mark
Newbie
 
Join Date: Aug 2007
Posts: 13
#3: Aug 29 '07

re: Load an External Javascript Function


Hi

Thanks for the Reply. But i think that u haven't got my question correctly. The problem is that the jsp makes a call to the external js external1.js, and one of the functions in external1.js makes a call to a function defined in another external javascript file external2.js.

Thank U
Mansoor.
epots9's Avatar
Moderator
 
Join Date: May 2007
Location: Canada
Posts: 1,313
#4: Aug 29 '07

re: Load an External Javascript Function


when you include the files it should be like this:
[html]
<script type="text/javascript" src="external1.js"></script>
<script type="text/javascript" src="external2.js"></script>
[/html]

can u can do function calls to the functions inside the other file, i done this in my code.
Also make sure you have a doctype.

good luck
Reply