HTML Navigation Bar Starting Backgrounds Debugging Netiquette Tables Text Tips Image Maps Graphics Frames Resources Help Hosting Sounds JavaScript Books E-mail Jim

jim's "HTML Spoken Here"© helps you Create a Personal Web Page


click for JavaScript samples






JavaScript is a scripting function that allows "client side" (on the viewing PC) dynamic behavior on your web pages. In the past, any dynamic behavior, like performing a calculation, would have to be done at the host and returned to the viewer.
(NOTE: There are no JavaScript examples on this page (in case your browser has problems with JavaScript or you have JavaScript turned off, you won't miss anything on this page). The references with by them contain active JavaScript examples.)

An example of dynamic behavior would be a home payment calculator.

Usually, the user would enter the loan parameters into a form and "submit" it to the host, where the calculation would be performed. The result would be returned on a separate page.

With JavaScript, the calculation can be performed on the page in the viewer's PC, without the delay of going back to the host.

JavaScript on HTML pages comes in two basic flavors.

  • JavaScript functions are stored by the browser (since they are usually included in the HEAD of a page) for execution later, when called from another JavaScript function or event action on the page.
  • JavaScript statements that are executed as soon as encountered by the browser or when elicited by an action (like a mouse click or on completion of page loading, etc.) on the page.
JavaScript code is hidden from the view of browsers, by commenting the script with the HTML comment tags, and does not display on the page. JavaScript functions are written in a format similar to "C" programs, but without the strong typing and strict formatting rules. JavaScript functions are not executed until called. Unlike "C", however, the JavaScript code is not compiled before execution. It is interpreted by the browser every time it is used.
Interpreting means that each line of code is looked at and executed per the rules built in to the browser each time the code needs to be executed. Normally computer programs are compiled once into machine instructions that can be executed any number of times by the PC's processor. The same "compiled" code can be executed repeatedly without recompilation.

With interpretation, you cannot force the PC to do anything not allowed by the browser's interpreter. Therefore, you cannot access memory outside the scope of your function and harm other parts of the PC's memory and, which is another important safety factor, you cannot access or otherwise modify the hard drive on a PC through a JavaScript function.

The most common use of JavaScript comes from the myriads of pre-defined functions available on the web (sites where you can get some of these finctions are shown on the JavaScript Samples page ).

These functions will allow you to use scrolling banners, add comments to the browser's status line (at the bottom of the window), display active clocks, perform financial calculations, change background colors, etc. There are literally hundreds of these "premade" JavaScript functions and Java applets that you can copy into your pages.
(Java applets are not JavaScript. They are functions written in the Java language and compiled into byte codes that can be processed by the browsers much like JavaScript. They are usually much more complex than JavaScript functions, typically involving complex graphics. JavaScript differs from Java in that it was originally called "LiveScript", created by Netscape to add dynamics to web pages. It is an object oriented scripting language that can be added to web pages by non-programmers. Java was developed by Sun, and is more like the C programming language, requiring the same level of training as would be required of a C programmer.)

JavaScript's real power comes in allowing you to specify the dynamics you would like for your page. This can include dynamic images, active link buttons, calculations (one JavaScript function that displays an active four function calculator can be found on the web), checking form entries, displaying different data based on a user's inputs, etc.

NOTE: If you click one of the "CLICK for" icons in the tutorial, a new browser window will be opened for viewing these pages. To return, you can just select this browser (from the task bar in Windows 95 or click your mouse somewhere on this window). You can also close (or File, Exit) from the new window when done, leaving only this window.

Internet Link Exchange
Member of the Internet Link Exchange Free Home Pages at GeoCities

Copyright © 1999 Jim Hanson Last update: Jan. 17, 1999     
This Page made with Ray Bradbury's
Homesite 3
.
This page hosted by GEOCITIES Get your own Free Home Page