Using External JavaScript Files


<script language="JavaScript" type="text/javascript"   src="/books/3/490/1/html/2/script.js"></script> 

Especially when you are reusing JavaScript code on your website, an external JavaScript file (or several files) comes in handy. This external file contains only the JavaScript code, no <script> elements. A <script> element is, however, used to load the external file, as can be seen from the previous listing (file scriptsrc.html). The src attribute holds the URL of the external script; absolute URLs (and, therefore, remote servers) are also possible.

Warning

Note that the code in the external file is available only after the external file has been fully loaded. So especially when calling functionality in the external file from the local page, keep in mind that the external file may not be available yet.





JavaScript Phrasebook(c) Essential Code and Commands
JavaScript Phrasebook
ISBN: 0672328801
EAN: 2147483647
Year: 2006
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net