There are two ways in which
you can add JavaScript to your webpage. These ways are:
Directly embed JavaScript
into HTML pages within HTML tags y using <SCRIPT> and </SCRIPT>
tags into the HTML file.
<SCRIPT type="text/javascript">
<!--
document.write("<i>This
is an embedded javascript!</i>");
//-->
</ SCRIPT
> |
ยท
Use JavaScript from an external source by including a separatel JavaScript
file having .js extension in the <SCRIPT> and </SCRIPT> tags.
The external file includes should always be in the <head> </head>
tags so that the browser is ready to execute scripts when the user calls
for them.
< SCRIPT
type="text/javascript" SRC="ExternalFile.js"> </ SCRIPT >
|
The external
JavaScript file will contain all the JavaScript code. The external file
is usually used when the same functionality is used in a number of web
pages in an application. It is quite similar to adding a .CSS file in
a HTML file.
Note:
JavaScript
Includes of external files are not supported by Netscape 2 and Explorer
3.
|