Introduction to Javascript - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Introduction to Javascript

Description:

A JavaScript is lines of executable computer code. A JavaScript can be inserted into an HTML page ... JavaScript is an open scripting language that anyone can ... – PowerPoint PPT presentation

Number of Views:253
Avg rating:3.0/5.0
Slides: 17
Provided by: laure3
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Javascript


1
Introduction to Javascript
  • Dr. Lauren B. Eder
  • CIS 340Electronic Commerce
  • Fall 2003

Adapted from W3Schools.com
2
What is JavaScript?
  • JavaScript is a scripting language
  • A scripting language is a lightweight programming
    language
  • A JavaScript is lines of executable computer code
  • A JavaScript can be inserted into an HTML page
  • JavaScript is an open scripting language that
    anyone can use without purchasing a license
  • JavaScript is supported by all major browsers
    like Netscape and Internet Explorer

3
How Does it Work?
  • When a JavaScript is inserted into an HTML
    document, the Internet browser will read the HTML
    and interpret the JavaScript. The JavaScript can
    be executed immediately or at a later event.

4
What can a JavaScript Do?
  • JavaScript gives HTML designers a programming
    tool
  • JavaScript can put dynamic text into an HTML page
  • JavaScript can react to events
  • JavaScript can read and write HTML elements
  • JavaScript can be used to validate data

5
How to Put a JavaScript Into an HTML Document
  • document.write("Hello World!")

6
Where to put Javascript code
  • Scripts can be inserted in the HEAD section or
    the BODY section.
  • Scripts in the head section will be executed when
    called.
  • Scripts in the body section will execute while
    the page loads.

7
Javascript in the Head section Triggered by the
onload tag
  • function message()
  • alert("This alert box was called with the onload
    event")

8
Javascript Inserted in the Body Section
Executes when Page Loads
  • document.write("This message is written when the
    page loads")

9
Variables
  • A variable is a "container" for information you
    want to store.
  • Rules for Variable names
  • Variable names are case sensitive
  • They must begin with a letter or the underscore
    character
  • You assign a value to a variable like this
  • var strname Broncos"
  • Or like this
  • strname Broncos"

10
Variables - Example
  • var name Broncos"
  • document.write(name)
  • This example declares a variable, assigns a
    value to it, and then displays the variable.

11
JavaScript Operators
  • Operators are used to operate on values.
  • The W3Schools page gives you possible operators

12
Javascript Functions
  • A function is a reusable code-block (set of
    statements) that will be executed by an event, or
    when the function is called.
  • A function contains some code that will be
    executed by an event or a call to that function.
  • You can reuse functions within the same script,
    or in other documents.
  • Functions are defined in the Head section and are
    called later in the document.

13
JavaScript Conditional Statements
  • Conditional statements in JavaScript are used to
    perform different actions based on different
    conditions.

14
Javascript Looping
  • Looping statements in JavaScript are used to
    execute the same block of code a specified number
    of times.

15
Javascript Guidelines
  • Click here for some good things to know about
    Javascript

16
Javascript Examples
  • Click here for some examples
  • Try inserting some of these into your Web pages
    to see the effects
  • More Free Javascript Samples
Write a Comment
User Comments (0)
About PowerShow.com