tags:

views:

127

answers:

5

Hello,
In file1.js inside a function I need to call a function which is actually included in file2.js

How can I do it?

Thank you

Later edit: This is what I want:

function back(){
if (step!=0){
dijit.byId('stackContainer').back();
}else{
//here I should call the save() function from file2.js
}
}

+1  A: 
<script type="text/javascript" src="file2.js"></script>
<script type="text/javascript" src="file1.js"></script>
David Dorward
+2  A: 

You need to include both of the javascript files in the same HTML page:

<script type="text/javascript" src="file2.js"></script>
<script type="text/javascript" src="file1.js"></script>
Kaleb Brasee
+3  A: 

Include both the js files in the same document. Then you can call one function in a js file from the other one.

rahul
+2  A: 

You simply need to be careful with the ordering of the javascript file includes. Make sure that the file containing the function you want to call is included in the document first. Once the function is defined, it can be used.

tvanfosson
+3  A: 

If you have multiple js files, you simply include all the files in the html page that you are using to call them. since javascript is globalised once you include it, you can call methods from another js file from a particular js file as long as both js files are included in the page.

Kamal