How to use external javascript file into HTML page.

Leave a Comment

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.

The external script cannot contain the <script> tag!

To use the external script, point to the .js file in the src attribute of the <script> tag as shown:
<html>
<head>
<script type="text/javascript" src="xxx.js"></script>
</head>
<body>
</body>
</html>

0 comments:

Post a Comment