JS Part1
JS Part1
JS Part1
Chapter 4
Outline
Overview of JavaScript
JavaScript basics
JavaScript Primitives
JavaScript Objects
Control statements
Object Creation and modification
Arrays
Functions
Regular Expressions
Client-side scripting
Why use client-side programming?
CS SS
usability: can modify a security: has access
page without having to to server's private data;
post back to the server client can't see source
(faster UI) code
efficiency: can make compatibility: not
small, quick changes to subject to browser
page without waiting compatibility issues
for server power: can write files,
event-driven: can open connections to
respond to user actions servers, connect to
like clicks and key databases, ...
presses
What is JavaScript?
a lightweight programming language (scripting)
var question =
confirm("Do you want to continue this download?");
The prompt Method
This method displays its string argument in a dialog box
A second argument provides a default content for the user entry area
The dialog box has an area for the user to enter text
The method returns a String with the text entered by the user