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

Q1121 Is there a way to place all the functions in one JavaScript file, if there is, how would I call a function in that file from the HTML page?

You are here: irt.org | FAQ | JavaScript | source | Q1121 [ previous next ]

Put your script in a file with extension .js

If your script looks like this before:

<script language="JavaScript"><!--
// test of .js files
alert('js file loaded');
//--></script>

The file test.js looks like this (cut and paste what is between the script tags except the javascript cloak comments:

// test of .js files
alert('js file loaded');

And the script tags now look like this:

<script src="test.js" language="JavaScript"></script>

Your server needs to have the mime type application/x-javascript set up for .js extensions. One server that doesn't have that as default is IIS3. The SRC attribute of the script tag is not supported by Netscape Navigator 2 and Internet Explorer 3.

©2018 Martin Webb