Presented at ~conf July 14, 2003 by Andrew Hedges, Design Team Manager, Interactive Multimedia Applications Group
How to insert JavaScript in a Web page
There are two ways to insert JavaScript in a Web page: inline or linked. Inline means the script is embedded in the page, like in the example below. Typically, scripts are put in the <html> <head> <title>My Page</title> <script type="text/javascript"> // my script can go here </script> </head> <body> <script type="text/javascript"> // or my script can go here </script> </body> </html> You can also link to a script in an external file. This is useful when you have a script that will be reused on multiple pages (like a DHTML menus script). Linking to scripts has the following advantages:
The code to link to a script is shown below. <html> <head> <title>My Page</title> <script type="text/javascript" src="scripts/myscript.js"></script> </head> <body> <!-- my page --> </body> </html> |
Document URL: http://www.gwu.edu/~ahedges/javascript/
Copyright © 2003, The George Washington University. All rights reserved.