CERTIFICATE IN JAVA SCRIPT -(C1099)
			
				
		        
			        
			             
		             
        			
        			
        				
        					
JAVA SCRIPT
 - What is JavaScript?
- History
- Uses
- Adding JavaScript to HTML
- JavaScript syntax
- JavaScript events
- JavaScript classes
- The HTML Document Object
     Model
- What is JavaScript?
 
 - JavaScript is a programming language for use in 
- HTML pages
 
 - Invented in  at
     Netscape Corporation 
- (LiveScript)
 
 - JavaScript has nothing to do with Java
 
 - JavaScript programs are run by an interpreter built 
- into the user's web browser (not on the server)
- Where does JavaScript Fit In?
 
 - Recall
- .
- client opens connection to server
- .
- client sends request to server
- .
- server sends response to client
- .
- client and server close connection
 
 - What about Step ?
- .
- Client renders (displays) the response received from
     server
 
 - Step  involves
     displaying HTML
 
 - And running any JavaScript code within the HTML
- What can JavaScript Do?
 
 - JavaScript can dynamically modify an HTML page
 
 - JavaScript can react to user input
 
 - JavaScript can validate user input
 
 - JavaScript can be used to create cookies (yum!)
 
 - JavaScript is a full-featured programming language
 
 - JavaScript user interaction 
- does not require any 
- communication with the server
- ros and Cons of JavaScript
 
 
 - Allows more dynamic HTML pages, even complete web 
- applications
 
 
 - Requires a JavaScript-enabled browser
 
 - Requires a client who trusts the server enough to run the 
- code the server provides
 
 - JavaScript has some protection in place but can 
- still cause security problems for clients
 
 - Remember JavaScript was invented in  and web-
- browsers have changed a lot since then
- Using JavaScript in your HTML
 
 - JavaScript can be inserted into documents by 
- using the 
- SCRIPT
- tag
- Where to Put your Scripts
 
 - You can have any number of scripts
 
 - Scripts can be placed in the 
- HEAD
- or in the 
- BODY
 
 - In the 
- HEAD
- , scripts are run before the page is displayed
 
 - In the 
- BODY
- , scripts are run as the page is displayed
 
 - In the 
- HEAD
- is the right place to define functions 
- and variables that are used by scripts within the 
- BODY
- External Scripts
 
 - Scripts can also be loaded from an external file
 
 - This is useful if you have a complicated script or 
- set of subroutines that are used in several different 
- documents
- avaScript Variables
 
 - JavaScript has variables that you can declare with 
- the optional 
- var
- keyword
 
 - Variables declared within a function are local to 
- that function
 
 - Variables declared outside of any function are 
- global variables
- JavaScript Operators and Constructs
 
 - JavaScript has most of the operators we're used to 
- from C/Java
- Simple User Interaction
 
 - There are three built-in methods of doing simple 
- user interaction
 
 - alert(msg)
- alerts the user that something has happened
 
 - confirm(msg)
- asks the user to confirm (or cancel) 
- something
 
 - prompt(msg, default)
- asks the user to enter some text
- avaScript Functions
 
 - JavaScript lets you define functions using the 
- function
- keyword
 
 - Functions can return values using the 
- return
- keyword
- JavaScript Arrays
 
 - JavaScript has arrays that are indexed starting at 0
 
 - Special version of 
- for
- works with arrays
- Exception Handling
 
 - JavaScript also has try, catch, and throw keywords for
     handling JavaScript errors
- Comments in JavaScript
 
 - Comments in JavaScript are delimited with // and /* 
- */ as in Java and C++
- avaScript Objects
 
 - JavaScript is object-oriented and uses the same  method-calling syntax as Java
 
 - We have already seen this with the  document object
 
 - Built-In JavaScript Objects
 
 - Some basic objects are built-in to JavaScript
 
 - String Date Array Boolean Math
- JavaScript Strings
 
 - A String object is created every time you use a 
- string literal (just like in Java)
 
 - Have many of the same methods as in Java
 
 - charAt, concat, indexOf, lastIndexOf, match, replace,
     search, 
- slice, split, substr, substring, toLowerCase, toUpperCase,
     
- valueOf
 
 - There are also some HTML specific methods
 
 - big, blink, bold, fixed, fontcolor, fontsize, italics,
     link, small, 
- strike, sub, sup
 
 - Don't use the HTML methods (use CSS instead)
 
 - This is the worst kind of visual formatting
 
 
 - The Date class makes working with dates easier
 
 - A new date is initialized with the current date
 
 - Dates can be compared and incremented
- JavaScript Arrays and Booleans
 
 - We have already seen the Array class
 
 - The Boolean class encapsulates a boolean value