Programming and Scripting
|
Static
HTML
pages can be supplemented with server or
client-side programming, or 'scripting' as it is often known.
Currently the main languages for this are
PHP,
Perl,
Java, and
JavaScript,
sometimes used in combination with CGI.
|
There are two kinds of scripting:
server side,
and client side.
The Common Gateway Interface, or CGI,
permits interactivity between a client and a host operating
system through the World Wide Web via the
Hyper Text Transfer Protocol (HTTP).
It's a standard for external gateway programs to interface
with information servers, such as HTTP or Web servers.
A plain
HTML document that the Web
server delivers is static, which means it doesn't change.
A CGI program, on the other hand, is executed in real-time,
so that it can output dynamic information - perhaps a weather
reading, or the latest results from a database query.
CGI allows someone visiting your Web site to run a program on
your machine that performs a specified task.
A client-side
script is a program that may accompany an
HTML page or be embedded directly in it.
The program executes on the client's machine when the page loads,
or at some other time such as when a link is activated.
Scripts offer you a means to extend
HTML pages in highly
active and interactive ways.
A web browser provides a host environment for client-side computation
including, for instance, objects that represent windows, menus,
pop-ups, dialog boxes, text areas, anchors, frames, history, cookies,
and input/output.
Client-side JavaScript statements embedded in an HTML page can
respond to user events such as mouse-clicks, form input, and page
navigation. For example, you can write a JavaScript function to verify
that users enter valid information into a form requesting a telephone
number or zip code. Without any network transmission, the HTML page
with embedded JavaScript can check the entered data and alert the user
with a dialog box if the input is invalid.
Dynamic HTML
is typically used to describe the combination of
HTML,
style sheets
and scripts that allows a web page to change after it's
loaded into the browser - there doesn't have to be communication with
the web server for an update. You can think of it as 'animated'
HTML.
For example, a piece of text can change from one size or color to
another, or a graphic can move from one location to another, in
response to some kind of user action, such as clicking a button.
Generally,
- Scripts may be evaluated as a page loads to modify the
contents of the page dynamically.
- Scripts may accompany a form
to process input as it is entered.
Pages may dynamically fill out parts of a
form based on the values of other fields.
They may also validate input data.
- Scripts may be triggered by events that affect the page,
such as
- selection,
- error and abort,
- form submission,
- change of element focus,
- page and image loading, and unloading,
- mouse movement, and other mouse actions,
- etc.
Scripting code appears within the HTML and the displayed page is a
combination of user interface elements and fixed and computed text and
images.
The scripting code is reactive to user events
and there is no need for a main program.
- Scripts may be linked to
form controls
(e.g., buttons) to produce graphical user interface elements.
Selena Sol's WebWare Monthly
A monthly column for the cultural anthropologist and other liberal arts
hackers gone Webmaster.
Introduction to Web Programming
A four half-day course designed by
Selena Sol.
- The Basics of Web Programming
- The Common Gateway Interface (CGI)
- Java Basics
- Advanced Java
Selena contributes The WDVL's
WebWare Monthly column, and wrote our
Introduction to Web Design
tutorial on HTML. He is well-known for his
Public Domain CGI Script
Archive and several books on Web Programming (Perl, CGI, Java).
JavaScript Tutorial for Programmers
This JavaScript tutorial is aimed primarily at those who have
had at least some exposure to another programming language.
It is not our purpose here to cover the basic concepts of
computer programming, but rather illustrate the syntax and
methodology of JavaScript. For its part, JavaScript is a rather
basic language which conforms tightly to the core concepts of
computer programming. Any background in programming, from Visual
Basic to Pascal to C (which is far more advanced) is sufficient
to readily understanding JavaScript.
|