• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Part III: Appendixes > Linking JS and HTML Files

Linking JS and HTML Files

Some web authors prefer not to mix JavaScript and HTML code in one document. For tidiness and efficient authoring, they move the JavaScript code to an external document, named with the .js file extension, and link that file to the HTML file. When a JS file is linked to an HTML document, the JavaScript interpreter treats the two files as one. Any JavaScript functions in the JS file can be called on from the HTML file and executed. To link an HTML file to a JS file, use the <script> tag with the following syntax and with no contents:

<script language="JavaScript" src="MyScripts.js"></syntax> 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint