Using an External JavaScript

If you want to run the same JavaScript on several pages, without having to write the same script on every page, you can write a JavaScript in an external file.  Save the external JavaScript file with a .js file extension.

Note: The external script cannot contain the <script></script> tags!

To use the external script, point to the .js file in the “src” attribute of the <script> tag:

Example:

<html>
<head>
<script type=”text/javascript” src=”xxx.js”></script>
</head>
<body>
</body>
</html>

Note: Remember to place the script exactly where you normally would write the script!