tags within the
or < tags and writing JavaScript code directly in the page. 2. By placing JavaScript code within HTML comment tags to avoid it being executed. 3. By saving JavaScript code in an external .js file and linking to it using aJavasript Codes
Javasript Codes
<html>
<body>
<script type="text/javascript">
document.write("Hello World!");
</script>
</body>
</html>
output on an HTML page: Hello World!
Sometimes you might want to run the same JavaScript on several pages, without having to write
the same script on every page.
To simplify this, you can write a JavaScript in an external file. Save the external JavaScript file with
a .js file extension.
To use the external script, point to the .js file in the "src" attribute of the <script> tag:
<html>
<head>
<script src="xxx.js"></script>
</head>
<body>
</body>
</html>