Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Source | Q1738 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.