JS - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

JS

Description:

In the body of an HTML page (after all the elements it may ... Decrement. Increment. Modulo. Divide. Multiply. Subtract. Add / Concatenate. Control Structure ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 23
Provided by: stephann
Category:
Tags: decrement

less

Transcript and Presenter's Notes

Title: JS


1
JS
  • Javascript

2
Javascript
  • Client Side Scripting Language
  • Object Oriented
  • Event Driven

3
Places JS Lives
  • An External File
  • ltheadgt of an HTML file
  • In the ltbodygt of an HTML page
  • (after all the elements it may reference)
  • JS can be used in multiple locations in the same
    HTML document

4
A link to an external javascript document
A JS Script coded in the ltheadgt of an HTML
document
5
External JS Files
Dont put another set of ltscriptgt tags inside
your external JS docs
6
JS Inside HTML
7
Variables
  • All are untyped
  • Local Variables
  • Accessible only inside the current function
  • Global by assignment

8
Literals
9
Operators
10
Control Structure
  • If
  • If / else
  • Switch
  • For
  • While
  • For (object)

11
IF
  • If
  • If / Else

12
Switch
13
Loops
  • For
  • While

14
Looping over an Object
15
Functions
  • Declaring a Function
  • Calling a Function

16
Events
http//www.w3schools.com/jsref/jsref_events.asp
17
Events
18
JS Objects
  • Properties
  • A value held by an object
  • Methods
  • Act upon an object

A string property
A string method
19
String Methods
  • str.substr(start, length)
  • Returns a sub string
  • str.indexOf(seach)
  • Returns positoin of the first instance of search
  • str.replace(bad, good)
  • Replaces bad text with good text
  • str.split(delimiter)
  • Breaks string into an array at every instance of
    delimiter

20
String Properties
  • str.len
  • Returns length of a string

21
Math Methods
  • Math.ceil(x)
  • Rounds up to the next integer value
  • Max(x,y)
  • Picks the larger of the two arguments
  • Math.random()
  • Returns a random number between 0.0 and 1.0

22
Document Object
  • Properties
  • Document.URL
  • Returns current url and query string
  • Methods
  • document.writeln()
  • Prints a line in the current document
  • Document.getElementById(id)
  • returns an HTML element with the ID you provide
Write a Comment
User Comments (0)
About PowerShow.com