• No results found

Sld-Lect03-JavaScript-Introduction.pdfView Download

N/A
N/A
Protected

Academic year: 2020

Share "Sld-Lect03-JavaScript-Introduction.pdfView Download"

Copied!
33
0
0

Loading.... (view fulltext now)

Full text

(1)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 1

JavaScript –

Introduction

(2)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 2

What is JavaScript?

„

JavaScript was designed to add interactivity

“user-machine communication” to HTML pages

„

JavaScript is a scripting language

„

A scripting language is a lightweight “small”

programming language

„

JavaScript is usually embedded “surround something/set

in” directly into HTML pages

„

JavaScript is an interpreted language (means that scripts

execute without pre “beginning” compilation)

(3)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 3

Are Java and JavaScript the

same?

„

NO!

„

Java and JavaScript are two completely different

languages in both concept and design.

„

Java (developed by Sun Microsystems) is a

powerful and much more complex

(4)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 4

What Can JavaScript do?

„

JavaScript gives HTML designers a

programming tool

.

„

JavaScript can

react to events

.

„

JavaScript can

read and write HTML elements

.

„

JavaScript can be used to

validate data

.

(5)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 5

(6)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 6

Writing to the HTML Document

„

The HTML <script> tag is used to insert

a JavaScript into an HTML page.

„

JavaScript can be written in three ways:

1.

JavaScript in <body>

2.

JavaScript in <head>

(7)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 7

(8)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 8

(9)

Internet Technologies I Lect.03

(10)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 10

(11)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 11

(12)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 12

JavaScript Statements

„

Unlike HTML, JavaScript is case sensitive.

„

This JavaScript statement tells the

browser to write "Hello Dolly" to the web

page:

document.write("Hello Dolly");

(13)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 13

JavaScript Variables

„

Rules for JavaScript variable names:

…

Variable names are case sensitive (y and Y

are two different variables).

(14)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 14

Declaring (Creating) JavaScript

Variables

„

You declare JavaScript variables with the

var

keyword:

var x;

var carname;

„

After the declaration shown above, the variables are

empty (they have no values yet).

„

However, you can also assign values to the variables

when you declare them:

var x=5;

(15)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 15

Assigning Values to Undeclared

JavaScript Variables

„

If you assign values to variables that have

not yet been declared, the variables will

automatically be declared.

x=5;

(16)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 16

„

For more information about variables,

please go to:

(17)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 17

(18)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 18

JavaScript Operators

„

The + operator can also be used to add string

variables or text values together.

„

To add two or more string variables together,

use the + operator.

txt1="What a very";

txt2="nice day";

txt3=txt1+txt2;

(19)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 19

Adding

Strings and

Numbers

(20)

Internet Technologies I Lect.03

(21)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 21

„

For more information about operators,

please go to:

(22)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 22

(23)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 23

JavaScript Popup Boxes

„

JavaScript has three kinds of popup

boxes:

1.

Alert box.

2.

Confirm box.

(24)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 24

Alert Box

„

When an alert box pops up, the user will

have to click "OK" to proceed.

„

Syntax

(25)

Internet Technologies I Lect.03

(26)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 26

Confirm Box

„

A confirm box is often used if you want the user

to verify or accept something.

„

When a confirm box pops up, the user will have

to click either "OK" or "Cancel" to proceed.

„

If the user clicks "OK", the box returns true. If the

user clicks "Cancel", the box returns false.

„

Syntax

(27)

Internet Technologies I Lect.03

(28)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 28

Prompt Box

„

A prompt box is often used if you want the user to input a

value before entering a page.

„

When a prompt box pops up, the user will have to click

either "OK" or "Cancel" to proceed after entering an input

value.

„

If the user clicks "OK" the box returns the input value. If

the user clicks "Cancel" the box returns null.

„

Syntax

(29)

Internet Technologies I Lect.03

(30)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 30

„

For more information about Popup boxes,

please go to:

(31)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 31

(32)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 32

To Do

„

Refer to Lecture

Lect03-JavaScript-Introduction.pdf

”, you can

download it from:

(33)

Internet Technologies I Lect.03

-Waleed Ibrahim Osman 33

References

Related documents

Given estimates or measurements of lithogenic input fluxes, this model suggests it is possible to use suspended lithogenic particles to examine many important bulk marine

Koefisien korelasi uji regresi (R) ROA dan Tobin’s-Q sebesar 0,314 dan 0,216 (0,21-0,40) menunjukkan bahwa hubungan variabel GCG, Komposisi Aktiva, Kesempatan Bertumbuh,

BU/16MPSES contenitore 30 ml per feci in polipropilene tappo a vite rosso, con superficie di scrittura, confezione singola, sterile, con etichetta faeces container 30 ml

We recorded demographical data, heart rate, mean arterial pressure (MAP), oxygen saturation of hemoglobin (SpO2), RSS value, colonoscopy time, total dose of propofol,

2/26/2019 Stalk Borers Moving in Central and Southern Iowa | Integrated Crop

Dále je zpracován návrh s implementací aplikace pro rozpoznání dominantních rysů obličeje de- monstrující zvolené metody pro nalezení dominatních rysů (Houghova

Renewable Energy Systems for Commercial Buildings, American Institute of Architects, Minneapolis, Minn., 2006.. Renewal: Sustaining the Building Stock Through Preservation,

TO JE joŠ JeDnA RijEČ IZ NašeG diJAlEkta KOjA oTPrILike značI «ONo ŠtO sE DogOdilo».. erEignIës KOJim Se odREđuje