To Previous Chapter To Table of Contents To Bottom of Page To Next Chapter

CS 335/535 Web Programming - Week 3 - Introduction to Scripting Languages

  1. JavaScript and the Internet
    1. What is JavaScript?
      released by Netscape as LiveScript with Navigator 2.0beta
      1. The Client-Side Features of JavaScript
        • simple to use
        • dynamic (responds to events)
        • object-based
      2. Java vs. JavaScript
      3. New Features of JavaScript in Netscape Navigator 3.0
        • can change GIF and JPEG images automatically, at specifified time intervals, by clicking a button or icon, or moving the mouse over an object
        • can detect the presence of plug-ins on a Web page and tailor the user interface accordingly
        • can communicate with plug-ins on the same page
        • Java applets can communicate with JavaScripts
      4. The Server Side of JavaScript (requires LiveWire for SSI or IIS/PWS for ASPs)
    2. When To Use JavaScript?
      • moves action from the server to the client
      • can locally validate forms fields before submitting the form to the server
      • HTML documents can respond to local events
      • Web page developer can communicate info to/from applets and plug-ins
      • server-side JavaScript supports unique personalized user profiles
      • Server-side JavaScript enables users to access databases
    3. The Limitations of JavaScript
      • early versions had security flaws
      • Microsoft vs. Netscape "standards"

  2. The JavaScript Language
    1. Embedding JavaScript in HTML
      1. Using the SCRIPT Tag
        <SCRIPT LANGUAGE="JavaScript">
        <-- Hide the script
        :
        // end hiding -->
        </SCRIPT>

      2. Handling Events
        1. Changing background color
    2. JavaScript is case sensitive and uses new lines to terminate a line of code; semicolons can be used to separate lines of code on a line
    3. Variables and Literals
      • Numbers (real & integer)
      • Strings
      • Logical (Boolean)
      • Null
      1. Defining Variables (loosely typed)
      2. Scope of Variables
        • Global variables (default)
        • Local variables (use var to declare variable)
      3. Literally Literals
        • integer (decimal, hexadecimal, or octal)
        • float
        • Boolean
        • string (can use single or double quotes)
        • special characters (\b, \f, \n, \r, \t)
    4. Expressions and Operators
      1. Assignment Operators (=, +=, -=, *=, /=, %=, <<=, >>=, >>>=, &=, |=, ^=)
      2. Arithmetic Operators (+, -, *, /, ++, --, %)
      3. Bitwise Operators (&(AND), |(OR), ^(XOR), <<(Shift left), >> (Shift right), >>> (Zero-fill right-shift)
      4. Logical Operators (&&, ||, !)
      5. Comparison Operators (==, !=, >, <, >=, <= )
        JavaScript also supports: (condition) ? true_value : false_value
      6. String Operators (+ = concatenates)
      7. Order of Precedence(see pg. 509)
    5. Conditional Statements and Functions
      1. Conditional Statements: if (else)
      2. Loop Statements: for, while, and for...in
        break and continue statements
      3. Comments - JavaScript uses both // and /* */ to indicate comments
    6. Fundamentals of Objects
      1. Objects and Their Properties: ObjectName.PropertyName
      2. Defining Methods: ObjectName.MethodName
      3. Working with Objects
        1. for (variable in ObjectName) {statements}
          List the properties of the Math object
        2. with (ObjectName) { statements }
        3. ObjectName = new ObjectType(param1 [, pparam2,]...[, paramN])
        4. this refers to current object
      4. Creating New Objects
        ex.
        function dog(breed, age, weight) {
          this.breed = breed;
          this.age = age;
          this.weight = weight;
        }

        mydog = new dog("small mutt", 5, 25);

      5. Defining Arrays
        function MakeArray(n) {
          this.length = n;
          for (var i = 1; i <= n; i++)
            this[i] = 0;
          return this
        }

    7. Built-In Objects and Functions
      1. The String Object
        • Properties: length
        • Methods: (most bracket the object with HTML tags) anchor, big, fontcolor(color), italics, sup, toLowerCase
      2. The Math Object: List the properties of the Math object
      3. The Date Object
      4. Built-In Functions
        1. eval(string)
        2. parseFloat(string)
        3. parseInt(string [, radix])
        4. isNaN(testvalue)
        5. escape("string - character")
        6. unescape("string - ASCII code")
    8. Netscape Objects
      1. The Navigator Object Hierarchy
      2. The Importance of HTML Layout
      3. The Window Object
        • Properties: name, parent, self, top, defaultstatus, status, script, location, frame, history, navigator, document
        • Methods: Alert, Confirm, Prompt, Open, Close, SetTimeout, ClearTimeout, Navigate
        • Events: Onload, Unload
      4. The location Object
      5. The History Object
      6. The document Object
    9. The FORM Object
      1. Event Handlers
      2. The forms Array
      3. Form Object Methods
      4. The element Object
      5. The element Methods
    10. Windows and Frames
      1. The Window Object Properties
      2. The Window Object Method
      3. Dividing the Window into Frames
    11. JavaScript contains three user interfaces: alert(message), prompt(message, [Default]), confirm(message)

Links to pages displaying JavaScript

Other Javascript links

The Future of JavaScript

To Previous Chapter To Table of Contents To top of page To Next Chapter