Attaching Scripts


The alternative to embedding is attaching, where you put the JavaScript in a separate file. However, for a Web page to use the external script, you have to tell the browser where to find it.

To do this, you use the src attribute of the script tag, like so:

 <html>   <head>     <title>Page Title</title>     <script language="JavaScript" src="/books/2/30/1/html/2/../scripts/myscript.js">     </script>   </head>   <body>     <!-- The content of the page goes here. -->   </body> </html> 

The src attribute gives the path from the current page to the script file that you want to attach, just like a hyperlink.



Web Design Garage
Web Design Garage
ISBN: 0131481991
EAN: 2147483647
Year: 2006
Pages: 202
Authors: Marc Campbell

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