Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1738 How can a function in one *.js file call another function in a second *.js file?

You are here: irt.org | FAQ | JavaScript | Source | Q1738 [ previous next ]

It is necessary to define the function before invoking it. Therefore it is best to reorder the inclusion of the *.js files in your page. For example:

<html>

<head>

<script language="JavaScript" src="test1.js"></script>
<script language="JavaScript" src="test2.js"></script>

</head>

<body>
...
</body>

</html>

where test1.js contains:

function functionName() {
  alert('Hello world');
}

and test2.js contains:

functionName();

Feedback on 'Q1738 How can a function in one *.js file call another function in a second *.js file?'

©2018 Martin Webb