When Web pages contain long scripts or functions that will be used by other documents, these scripts can be placed in external files. The external JavaScript files must end with a .js extension. The name of the external JavaScript file is assigned to the src attribute of the <script> tag in the HTML file. The name includes the full URL if the script is on another server, or just the script name if in the local directory. You can include more than one .js script in a file. <script language="JavaScript" src="http://servername/javascriptfile.js"> </script> Example 1.6<html> <head><title>First JavaScript Sample</title> 1 <script language = "JavaScript" src="welcome.js"> 2 </script> </head> </body> 3 <script language = "JavaScript"> 4 document.write("<body bgcolor='yellow' text='blue'>"); document.write("<font size='+3'>This is just plain old HTML stuff. </font>"); </script> </body> </html> EXPLANATION
|