21js-2up - 21 JavaScript 07 Oct 2010 CSCC09F Programming on...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
21 JavaScript 07 Oct 2010 CSCC09 Programming on the Web 1 21 - JavaScript CSCC09 1 Client-Side Scripting Client-side scripting, JavaScript overview, JavaScript language, DOM CSCC09F Programming on the Web 21 - JavaScript CSCC09 2 History and Java Relationship b Microsoft has a similar language called JScript b JavaScript and Java are complementary c JavaScript b cannot draw, multi-thread, network, or do I/O c Java (Applets, for client side, covered separately later) b cannot interact with browser or control page content c note , JavaScript and Java can work together on the same document, to jointly accomplish task neither could perform independently b Netscape originated LiveScript , later renamed to JavaScript at the last minute. c Invented by Brendan Eich at Netscape c Perceived competition with Sun Microsystems’ Java applets for client-side programming
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
21 JavaScript 07 Oct 2010 CSCC09 Programming on the Web 2 21 - JavaScript CSCC09 5 Client-Side Scripting b download a script/program to the browser, and have it execute within the browser environment: c JavaScript / ECMAScript / JScript c VBScript c TCL c (time permitting, we may talk about client-side compiled “programs” separately – e.g. Java Applets) b we will examine JavaScript as a proxy for this group of client-side languages; much of what we study is immediately transferable to other languages in this category b JavaScript is the dominant client-side programming language – the basis for much of RIA, Web 2.0 21 - JavaScript CSCC09 6 Client-Side Scripting b advantages of client-side scripting: c immediate responsiveness – no need for network data exchange with server b e.g. customer wants to see the product in yellow not red c offloads processing tasks to client that is usually less loaded than server b disadvantages of client-side scripting: c scripts must be downloaded from server, increasing size and time for page loads c scripts are readable, can’t protect source code, though can obfuscate them c security risk posed by downloaded code; e.g. much of today’s malware incorporates client-side scripting
Background image of page 2
21 JavaScript 07 Oct 2010 CSCC09 Programming on the Web 3 21 - JavaScript CSCC09 8 Desired Functionality In approximate order of appearance: c Language to compute on the client – computational tasks like auto-summing values, offload busy server c Process HTML-form input b “validate” form input values before sending to server c Ability to interact with displayed document: read+write page content, interact with browser s.a. opening windows, trigger/detect events, change style style c Server-side data retrieval: ability to update page based on content obtained from server without page refresh 21 - JavaScript CSCC09 9 Form Validation Example b validateNumeric.html b notice: c use of function designed for general use validating multiple fields with similar restrictions on use c object to be validated (form field) is passed to function as a parameter rather than writing explicit page addressing into the function
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 23

21js-2up - 21 JavaScript 07 Oct 2010 CSCC09F Programming on...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online