Docsity

Web Application Software Development - Introduction to Java Script - Lecture Slides, Slides of Javascript programming

Partial preview of the text

Download Web Application Software Development - Introduction to Java Script - Lecture Slides and more Slides Javascript programming in PDF only on Docsity!

Introduction to JavaScript

Web Application Software Development

Outline – Part A

  • Overview of JavaScript
    • Versions, embedding, comments
  • JavaScript Basics
    • Variables and Data Types
    • Operators
    • Expressions
  • JavaScript Control Structures
    • Conditional Statements
    • Looping Statements

Outline – Part C

  • Working with Browser Objects
    • Document Object Model (DOM)
  • Creating Cookies in JavaScript
    • Constructing a standard cookie
    • Interaction with the cookie
  • Introducing DHTML
    • Styles and Layers
    • Dynamic Positioning

Outline – Part D

  • JavaScript Application Development
    • JavaScript Example
    • Discuss the execution requirements
    • How to break down the syntax
  • Cool JavaScript Sites
  • JavaScript and DHTML Reference
  • Hints for JavaScript coding
  • Summary

JavaScript Capabilities

  • Improve the user interface of a website
  • Make your site easier to navigate
  • Easily create pop-up alert, windows
  • Replace images on a page without reload the page
  • Form validation
  • Many others …

JavaScript Versions

  • • JavaScript 1.
    • • Supported by Netscape 2.0 and IE 3.
  • • JavaScript 1.
    • • Supported by Netscape 3.0 and IE 4.
  • • JavaScript 1.
    • • Supported by Netscape 4.0 and IE 4.
  • • JavaScript 1.
    • • Supported by Netscape 4.5 and IE 5.
  • • JavaScript 1.

A Simple Script

First JavaScript Page

First JavaScript Page

Embedding JavaScript

  • A

Need for a source file

  • If the JavaScript code is fairly short, you are recommended to include the code in the HTML document.
  • To add clarity to an HTML document.
  • To share JavaScript code across multiple HTML documents.
  • To help you hide your JavaScript code.
    • Spent lot of time for JavaScript coding.
    • Viewer can only see the location of the source file but not the contents.

Hide JavaScript from incompatible browsers

  • Not all browsers support JavaScript.
  • E.g. NN1, IE2, character-based lynx.

Your browser does not support JavaScript.

Using the alert() Method

  • It is the easiest methods to use amongst alert(), prompt() and confirm().
  • You can use it to display textual information to the user (simple and concise).
  • The user can simply click “OK” to close it.

Using the confirm() Method

  • This box is used to give the user a choice either OK or Cancel.
  • It is very similar to the “alert()” method.
  • You can also put your message in the method.

Three methods

Variables

  • JavaScript allows you to declare and use variables to store values.
  • How to assign a name to a variable?
    • Include uppercase and lowercase letters
    • Digits from 0 through 9
    • The underscore _ and the dollar sign $
    • No space and punctuation characters
    • First character must be alphabetic letter or underscore – 99Total?, 012345number?, …
    • Case-sensitive
    • No reserved words or keywords