JavaScript
An Introduction
Part I: Structure of a JavaScript program
JavaScript Characteristics
- scripting language
- embeded directly inside of the HTML file
- is interpreted by code in the browser on the client side.
- because it is downloaded in an uncompress format, you need to
be conscience of the size of the code you are downloading.
- typically used for simple graphical interfaces.
- simple language that due to some lack of structure for a programmer
can be unintuitive...but, for a non-programmer possibly easier than
other languages.....really developed for the non-programmer.
- JavaScript code is surrounded by the following. Note:
the code is encodes inside of an HTML comment....this is not require
but, good practice in case someone with a very old browser does
not recognize JavaScript this will insure it doesn't choke and will
display the rest of the HTML.
<SCRIPT Language="JavaScript">
<!--
THE
JavaScript Code GOES HERE
// -->
</SCRIPT>
|
- Location of Code:
- if in <HEAD> statement than this is where you will put
functions, etc.
- if in <BODY>, this is where you will put the code that
actually executes possibly using funcitons from the code in
the <HEAD> portion of the HTML.
|
JavaScript Uses/Capabilities
- Can generate HTML dynamically.
- Used for simple user interface interactions: button roll-overs,etc.
- Can make Java calls directly from JavaScript, to extend the
possibilities greatly using Java.
- Can be used to check data in form before sending off to a CGI-script
on the server for processing.
|
Next: Objects and Classes, and Functions.
|