INTRODUCTION TO JAVASCRIPT
JAVASCRIPT IN WEB PAGES
‘Today's web sites need to go mach beyond HTML. Ther i «defisite sed slow user, browsing
Semen eet eters Tse es ig
‘ses adamily racie e paetn ae mane ge TR
Thaw tea te drones evo ha wil sow th eran of Interethe we pge,
acer yet for End on he pt mes er ee
in content and presentation, to the user. aad
Ia he sso ye pth bt tb i om
conan eter! inating, MEA 8 tt web ae
Cptuing user requests is eaitionally done via a
eto ts ena kastonly dove vis + Form. Hence the web ste deepest enroamet
ed om UPMEES tip, te frm mse + bit chu fr senda he ination
ter requests is generally done via scrip
‘captured back t the web server for procesing |
(mal programs) that are based on the terver
ovr oe INTRODUCTION To JAVASCRIPT Paes
[Addiocally, all development environments provide syetax o erate and use memory varinbles, consti,
td fintione
If the development envconment is objet oriented it wil provide an object hierarchy to work with. An
Objet Oriented Programming (OOF) envitonment always offers event crvenprogeming. This mesa
thatthe programming environment will recognize object bared events and allow the connection of code
‘aipptsto these evets, When an event our, the code sippes wil execs
All ese ates and more ae availble in JvaScrip,
Netscape and JavaScript
JInaSerge is a scripting language (web site development environment) crated by Newcape hence
SaaSerpe works best withthe Netscape suite of Client and Server produ,
‘The Netscape client browser product is called Netscape Cornmuricator. The defel serpting language
that Nevespe Communicator understands is avaSerip.
(One Netscape server product, fom it suit of server products, is Neweape Commerce Server. The default
sesping language hat Netscape Commerce Server understands i JavaSei.
Datebase Connectivity
Netscape tas 2 product called Live Wire, which permis server side, InaScrpt code, to connect 10
Relator DataBase Management Systems (RDBMS). RDBMS such as Oracle, MS SQL Server, MySQL,
‘mSQL and a hos of eter widely used relational databases, which generally se ANSI SQL. a thir tra
langue. Live Wire database divers aso support» numberof non-reiational databace,
Client side JavaScript
Cliencside JavaScript is tational embedded into standard HTML program JavaScript is embedded
between the HTML tags. These gs are embeded within the .
= SIHIEAD> or ... as ofthe HTML program.
aaScrp is embedded ino an HTML program because JavaSrit uses the flename il and the HTTP
rotor to transport itself fom the webserver othe clients browacr where the JavaSerigt executes and
roses lent information.
Only » browser that is JavaScript enabled will be able to imerpet JavaScript code. —Netéape
[Communicator does his best a JavaScript i he natural language of Neteape Communica
Micros Internet Explore lio interprets JavaScript. However, Item Explorer atest relates support
nol version of JavaSerit. Hence, he total funetionality ofthe atest reese of IvaScrpt sealable
‘a Neseape Communicators not avaiable in internet Explore.
IN
‘map Me cet scr gue of ere plore is VB Sep. Neseape Crm oes at
supprt VB Sept
Capturing User Input
‘Wb sie interactivity starts fom being able to capture user input. The HTML
tags can te use wo create a user Requestform. Between these HTML tage the HTML
“ gs can be used fo instantiate HTML objects in the HTML form to filme the cape of wer
uaTew aves ne
Tet rgued cnn be bac
‘The place of deliver (address) cannot be lf blank
some development
‘he fneonality oF HTML pages already ona web sie nT a8 tly aod Quickly wed to extend
The Advantages Of JavaScript *
‘An Interpreted Language: JaveSe
This provides an easy deveiopmen
interrets HTME ag ge
char 08 INTRODUCTION To JAVASCRIPT PAGE 427
[Enbeded Within HTML: JvaSrp doe ot equi ny spacial or spate eof progr tobe
wien edited oc compile Kean be wn in any et edt ke Noten, lng with zpptonete HTML
Tah ed saved 8 leno ha HTML fee id eobeas ees ee TM
intrpied ty ony bowoa at save ule
‘Minimal Syntax ~ Easy to Learn By lain usa few commands and simple rules of syriay, complete
ppienons canbe bull using JvaSerip.
Quick Development: Because JavaScript doesnot reuite tine consuming compton, serps can be
developed in » shor period of time. Tis is enhanced by the Get that many GUI interface fests, such as
sles, romps, confinn bones, and ther GUI elements, are handled by ele ide avaSei,the browser
tnd HTML code
Designed for Simple, Small Programs: It is well suited to implement simple, small programs (or
‘xan, unt conversion caleuletorbenveen miles and kilometers, or pounds ond tlogrant). Sich
‘rograns can be easily writen and executed at an acepable speed using JaaSerp. In addon, they can
‘be eal integrated into a webpage.
Performance: nvaSrit canbe writen sch thatthe HTML fils ae fil compact and quite smal, This
smiimizes storage equvement on the web server and download ine fort cio.
‘Aaitonlly, because Javacripxprogams ae usually included inthe same fle asthe HTML code or 8
webpage, they require fewer septate network accesses,
Procedural Capabilities: Every programming language needs to support files such as Condon
shecking, Looping and Branching. JveSerpt provides syntax, which canbe wed to add such proses
“apabilties io web page (floname bm! coding
Designed for Programming. User Events: InvaScript sopporte ObjecvEvent based programing,
JavaScpt recognizes when 4 form Bulton is preseed, The event can have witable JavaSerpt code
tached, whi will execute when he Button Pressed event ours.
JuvaSeipt can be used to implrent content sensitive help. Whenever an HTML fons Mouse corso
"Moves Over a buton or lnk onthe pages helpful and inforative message can be dapaye in testis
barat te botom ofthe browser window.
Easy Debugging and Testing: Being an ierpced language, seit in JavaScript ar ested line by line,
andthe errors are also listed a they ve encountered, a appropriate eror message along with the ine
‘number is listed for every eo tha is encountered. its eny 10 locate ers, make changes, ad et
‘gain without the overhead and dl of compiling
‘Platform Independence / Architecture Nears isa programming language tha is completely
independent ofthe hardware on which it works. ICs language that is underdood by any JowSeript
enabled browser, Thos, JavaScript applications work on sy machine tat bas en appropiate JavaScript
‘cuabled browser asad This machine canbe anywhere onthe network.
Since each browser is for a specific paform, JavaScript ieterpretation wl be with repectt the specific
lator. The browser will add whatever platform specific infrmaton i rege othe IaScrgt wil it
lterpres the code, Thus, JavaScript is truly platform independent. A JavaScript program developed 093
‘Unix machine will work perfectly well ona Windows machine.
‘The fc tha platform speife Bowser, msniained a the let end, does the interpretation of lvaSit,
relevesthe developer ofthe responsibilty of maintaining multiple sourcecode ies fr mil platform.'
PAGE 120 ‘CWAD USING HTL, JAVASCRIPT, OHTML AND PHP CHAP 08
WRITING JAVASCRIPT INTO HTML,
Sino a embed roan HTML Ribot eds HTML fs adie HTML aga.
brome nett net be clued a8 an integral pant of an HTML document whe aed a
Sea pts informed tat pci scion of HTML cate veep. The home woe
busin JavaScript engine to interpre thi cade,
mun given his iformacon wing he HTML ings mash endo ener
of serpting code
(ik mothe HTML tg, he