• No results found

Tutorial 10: Programming with javascript

N/A
N/A
Protected

Academic year: 2021

Share "Tutorial 10: Programming with javascript"

Copied!
21
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)
(2)

Session 2: What is JavaScript?

Tutorial 10: Programming

with javascript

(3)

What is JavaScript?

What can JavaScript do?

JavaScript – How to

Writing JavaScript Statements

JavaScript – Where to

Writing JavaScript Comments

Declaring Variables in JavaScript

Objectives

(4)

JavaScript was designed to add interactivity to HTML pages

JavaScript is a scripting language

– A scripting language is a lightweight programming language

JavaScript is an interpreted language (means that scripts execute without preliminary compilation)

Everyone can use JavaScript without purchasing a license

What is JavaScript?

(5)

JavaScript gives HTML designers a programming tool

JavaScript can read and write HTML elements

JavaScript can react to events

JavaScript can change HTML content

JavaScript can change HTML images

JavaScript can change HTML styles

JavaScript can be used to validate data

What can JavaScript do?

(6)

Example of JavaScript

Use

(7)

http://grhainfo.org/codingbootcamp2/regist ration.htm

http://www.gcsu.edu

Other Examples of

JavaScript Uses

(8)

A JavaScript program can be placed directly in an HTML file or it can be saved in an

external text file

Insert a client-side script in a Web page when using the script element

<script type="text/javascript">

script commands

</script>

JavaScript – How to..

(9)

In Class Example

– Writing to the HTML document – Changing HTML elements

JavaScript: Script

Element

(10)

JavaScript is a sequence of statements to be executed by the browser.

JavaScript is case-sensitive.

A JavaScript statement is a command to a browser. The purpose of the command is to tell the browser what to do.

Example:

document.write("Hello Dolly");

JavaScript Statements

(11)

In Class Examples

– JavaScript Code

– JavaScript Code Block (use of a function)

JavaScript Statements

(12)

JavaScript can be put in the <body> and in the <head> sections of an HTML page.

JavaScript can be embedded in the HTML code.

JavaScript can also be placed in external files.

JavaScript – Where to..

(13)

In Class Examples

– In body – In head

– External JavaScript file

JavaScript: in head,

body, and external

(14)

Commenting your code is an important programming practice

// comment text for a single line /* comment text for multiple lines

JavaScript Comments

(15)

In-Class Example:

– Add a single-line comment – Add a multi-line comment

JavaScript Comments

(16)

As with algebra, JavaScript variables are used to hold values or expressions.

A variable can have a short name, like x, or a more descriptive name, like carname.

Rules for JavaScript variable names:

– Variable names are case sensitive (y and Y are two different variables)

– Variable names must begin with a letter, the

$ character, or the underscore character

JavaScript Variables

(17)

Declaring a variable tells the JavaScript to reserve memory space for the variable.

To declare a JavaScript variable, use the statement var variable;

where variable is the name assigned to the variable.

To declare a JavaScript variable and set its initial value, use

var variable = value;

where value is the initial value of the variable.

Declaring JavaScript

Variables

(18)

JavaScript data types:

– Numeric values – Text strings

– Boolean values – Null values

You must declare a variable before using it.

Declaring JavaScript

Variables

(19)

Numeric value is any number, such as 13, 22.5, -3.14159 etc.

Text string is any group of text characters, such as “Hello” or “Happy Holidays!”

– Must be enclosed within either double or single quotations (but not both)

Boolean values accept only true and false values

Null value has no value at all

Declaring JavaScript

Variables

(20)

In Class Example

Declaring Variables

(21)

Declaring Variables

In Class Example

Referenties

GERELATEERDE DOCUMENTEN

Bijvoorbeeld progress = 0.5 betekent dat de halve duration gebruikt

De afbeelding worden keer op keer opnieuw getoond met kleine veranderingen waardoor een beweging gesimuleerd wordt.. Toon de afbeelding op

De achtergrond wordt gevormd door een achtergrond van sterren die feitelijk gemaakt worden met de grafisch mogelijkheden van CANVAS.. Dit zijn

JavaScript object attributes can be placed in HTML element tags.. e.g.,

– Markup language (HTML, XML, etc.) – Scripting language (JavaScript, etc.) – Presentation language (CSS etc.).

In 1997, Netscape and Microsoft released version 4.0 of Netscape Navigator and Internet Explorer respectively, adding support for Dynamic HTML (DHTML),.. functionality

– Markup language (HTML, XML, etc.) – Scripting language (JavaScript, etc.) – Presentation language (CSS etc.). What’s DHTML?.. • CS453 Virtual

While organizations change their manufacturing processes, it tends they suffer aligning their new way of manufacturing with a corresponding management accounting