Newbie Question: Connect Two Functions Int Two Files
This is a newbie question. I have two javascript and one html files. When I click on an image it goes to the first .js file and when it finnish to run all that code should go to th
Solution 1:
you need just to define the 2 js files in the HTML header page :
<scripttype="text/javascript"src="one.js"></script><scripttype="text/javascript"src="second.js"></script>
Solution 2:
It doesn't matter what files the functions are in, you can call the second function from the first one.
You should also consider why you are separateing your functions into seperate files - in general, they should all be in as few files as possible.
Solution 3:
Like so:
In file1.js:
var foo = function(){
bar();
};
In file2.js:
var bar = function(){
alert('hello');
};
Solution 4:
You will have something like this,
in the html file:
<inputtype="button" name="" onclick="random1();" />
in the first js file:
function random1(){
// your code hererandom2();
}
in the second js file:
function random2(){
//your code here
}
Post a Comment for "Newbie Question: Connect Two Functions Int Two Files"