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

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?

irt.org | Knowledge Base | JavaScript | source | Q1121 [ previous next ]

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?

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.


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.