Lecture 4: Application Architecture and Lifecycle

Download Report

Transcript Lecture 4: Application Architecture and Lifecycle

Lecture 3B:
Client-Side Scripting
IT 202—Internet Applications
Based on notes developed by Morgan Benton
For Today
Client-side scripting
Review of Client/Server Model
For networked applications, processing
power is a valuable resource
Most of the time both servers and clients
possess processing power (i.e. they each
have their own CPU)
The decision has to be made about whether
to run application logic on the client side, or
the server side of the application
Reasons for Using Client-Side
Scripting
HTML by itself is primarily for presentation
of static information and provides poor
support for interactivity
Using the client’s CPU for processing
improves response time of apps
Decreases the processing load of the server
making the server run more efficiently
Reasons NOT to use Scripts
Browser compatibility
Some users intentionally disable scripts in
their browsers
Scripts have limited permissions to
resources on users’ computers
Which Scripting Language?
A variety exist including JavaScript, Jscript,
VBScript, ECMAScript, Tcl
Only JavaScript is supported by all (or at
least most) browsers
ECMAScript is the standardized version of
JavaScript
What is JavaScript
JavaScript has almost no connection
whatsoever with the Java programming
language
Developed by Netscape
Has evolved into a standard supported by
ECMA (European Computer
Manufacturers’ Association)
A guideline for using scripts
A significant number of people think that
scripting should only be used for nonessential functions in a website. In other
words, a user should be able to make full
use of your site even if he/she doesn’t have
a browser that supports scripts or she/he has
scripts turned off.
Using Scripts within HTML
<script type=“text/ecmascript”
language=“JavaScript”>
<!-/* script goes here */
-->
</script>
Putting Scripts in a Separate File
<script
type=“text/ecmascript”
language=“JavaScript”
src=“path/to/script.js”>
</script>
In a separate file labeled script.js you would add your
code. This allows you to use the same code in many
documents without having to retype the code in each
one. Makes maintaining the scripts easier much as CSS
makes maintaining formatting for a site easier.
The DOM
DOM stands for Document Object Model
It is the way that you are able to access the
elements on your page
document is the top level object and
refers to the web page in which the script
resides
Let’s do it!
Together we will create a script that will
dynamically change a graphic on a web
page when a user mouses over it.