RaysWebClass.Com


Lesson 51:   Intoduction to JavaScript


  1. JScript: Do you want to know what it is?
    JScript is short for Javascript. JScript fills a gap that ASP can not fill. ASP is, as you now know, a very powerful programming language but it has one flaw; it does not run on the client side (end user) -- ASP is server side only. Therefore any Dynamic HTML such as mouse over, image swapping, or field verification (which is best done on the client-side) is accomplished by using JavaScript.
  2. JavaScript Syntax

  3. Examples

  4. Naming Convention
    For JScript to read or write to an element within a web page it needs to find the element. The follow chart is a hierarchical naming convention used by JavaScript to identify objects and their properties:
    For example, to write Hello in a textbox named text1 in a form on the page you would do: document.form.text1.value="Hello"
    Using ID's can simplify this ever further. For example if I create a textbox with an ID="Ray", I can access it by simply using document.all.Ray.value="Hello" The .all will search the entire document looking for an object with an ID="Ray".
  5. Events
    The following chart is a list of objects and their related events:
    Object Event Action
    Textboxes onBlur Tab away from this object or click on another object. Use this to verify field content.
    onFocus Tab to or click to this object.
    onSelect Select text.
    onChange Change text.
    onMouseOver Move the mouse over the object.
    onMouseOut Move the mouse off the object.
    Button onClick Mouse over and Click or Tab Enter.
    Radio onClick Mouse over and Click or Tab Enter.
    HyperLink onMouseOver Move the mouse over the object.
    onMouseOut Move the mouse off the object.
    onClick Mouse over and Click or Tab Enter.
    Body onLoad After the web page has completed downloading.
    onUnload Upon moving to another web page.
  6. JavaScript vs JAVA
    Lastly I would like to point out the differences between JavaScript and Java. The only thing the two languages have in common are the first four letter of there names! Well, not really. Javascript is a sub-set of the Java language, but JavaScript is written in the HTML code, Java is not. It's compiled using a Java compiler and placed separately on the server from the HTML that runs it. The following chart will display some of the major differenced between the two languages:

    JavaScript JAVA
    Designed by Netscape Designed by Sun Microsystems
    Resides and acts upon the entire Web page Resides out side the Web page and acts only upon the region where it is displayed
    Usable by non-programmers Requires programming experience
    Run's from within the client's browser Run's from standalone code outside the browser

Web Page Design: Exercise 51

Put all the above examples of JScript into one page.
Create a folder in the wwwroot called JScript and save this project as JScript51.html.