Title: The JavaScript Programming Language
1Introduction
- The JavaScript Programming Language
- Applets
- The Java Programming Language
- Web Page Counters
2The JavaScript Programming Language
- Introduction
- JavaScript and HTML
- Event Handlers
- Sample JavaScript Code
3The JavaScript Programming Language
Introduction
- Client-side Scripting language
- Not Java
- Statements usually embedded in HTML code
- Simple, interpreted programming language
4The JavaScript Programming Language
Introduction
- Common uses
- Alert boxes
- Color fades
- Dynamically converts form elements
- Information in status line
- Verify form input
5The JavaScript Programming Language
JavaScript and HTML
- ltSCRIPTgtlt/SCRIPTgt
- LANGUAGEJavaScript
- SRC
- program.js
6The JavaScript Programming Language
JavaScript and HTML
- ltSCRIPT LANGUAGE JavaScriptgt
- lt!- - Begin hiding for browsers that cannot
process JavaScript. - Include JavaScript statements here.
-
- Last JavaScript statement goes here.
- End hiding script. - -gt
- lt/SCRIPTgt
7JavaScript and HTML
ltHtmlgtltHeadgtltTitlegtonLoad Examplelt/Titlegt ltScript
Language JavaScriptgt lt!- - Begin hiding for
browsers that cannot support script. function
ready() document.forms0.elements0.valueLet
s go! //Stop hiding script. --gt lt/Scriptgt lt/Hea
dgt ltBody onLoad ready()gt ltFormgt ltInput Type
text Value Loadinggt lt/Formgtlt/Bodygtlt/Htmlgt
8The JavaScript Programming Language
Event Handlers
- onMouseOver and onMouseOut
- onMouseOver
- When you move mouse over item, action triggered
- onMouseOut
- When you move mouse out of area, action triggered
9The JavaScript Programming Language
Event Handlers
- onMouseOver and onMouseOut
- ltA HREF ASSIGNMENTS/assign.html
- onMouseOver document.images0.srcGRAPHICS/4
ON.GIF - window.status Assignments
- onMouseOut document.images0.srcGRAPHICS/4
OFF.GIF - window.status gt
- ltIMG SRC GRAPHICS/4OFF.GIF
- WIDTH 42 HEIGHT 42 ALT
Assignments - BORDER 0gt
- lt/Agt
10The JavaScript Programming Language
Event Handlers
- When user mouses over image
- Loads a new image
- Assignments displayed in status line
11The JavaScript Programming Language
Event Handlers
onClick and alert  ltA HREF killface.html
onClick alert(Thanks for loading
my pageKillface.)gt Killfaces Page lt/Agt
12The JavaScript Programming Language
Event Handlers
13Event Handlers
onChange and confirm ltHtmlgtltHeadgtltTitlegtConfirm
Boxlt/Titlegt ltScript Language JavaScriptgt funct
ion question(name) var theAnswer
confirm(Are you really name
?) lt/Scriptgtlt/Headgt ltBodygtltFormgt ltInput Type
text Value Enter your name
onChange question(value)gt lt/Formgtlt/Bodygtlt/Html
gt
14The JavaScript Programming Language
Sample JavaScript Code
- ltFORMgt
- Â
- ltSTRONGgt
- Temperature Conversion Example Using JavaScript
ltBRgt - lt/STRONGgt
- Â
- ltPgt nbsp lt/Pgt
- Â
15The JavaScript Programming Language
Sample JavaScript Code
- ltINPUT TYPE text
- NAME cels
- VALUE 0
- SIZE 3
- MAXLENGTH 3
- onChange fahr.value 1.8 value 32gt
- 176 ltSTRONGgtClt/STRONGgt
- nbsp ltSTRONGgtequalslt/STRONGgt nbsp
- Â
16The JavaScript Programming Language
Sample JavaScript Code
- ltINPUT TYPE text
- NAME fahr
- VALUE 32
- SIZE 3
- MAXLENGTH 3
- onChange cels.value (value - 32)/1.8gt
- 176 ltSTRONGgtFlt/STRONGgtÂ
- lt/FORMgt
17The JavaScript Programming Language
Sample JavaScript Code
18Applets
- Introduction
- HTML Applet Tags
- Java-Enabled Browsers
- Sample Applets
19Applets
Introduction
- Little application
- Primary features
- Information is dynamic
- Can respond to input
- Program downloaded from Web server
- Runs on the client
20Applets
HTML Applet Tags
- ltAPPLETgtlt/APPLETgt
- Attributes
- ALIGN ALT
- CODE CODEBASE
- HEIGHT HSPACE
- NAME VSPACE
- WIDTH
21Applets
Java-Enabled Browsers
- Browsers that are text-only or not Java-enabled
ignore applet tags - Display messages
22Applets
Sample Applets
- ltAPPLET CODE HiMom.class
- HEIGHT 75
- WIDTH 125gt
- ltPARAM NAME message
- VALUE Hi Mom. How do you like my
applet?gt - lt/APPLETgt
23Applets
Sample Applets
24The Java Programming Language
- Introduction
- Java and Object-Oriented Programming
25The Java Programming Language
Introduction
- Sun Microsystems, 1995
- Java Virtual Machine
26The Java Programming Language
Java and Object-Oriented Programming
- Java supports object-oriented programming (OOP)
- Object, Class
- Inheritance
27Web Page Counters
- HTML Code for a Counter
- Counter Usefulness
- Counter Display Decision
28Web Page Counters
HTML Code for a Counter
- Absolute URL for CGI script as value of SRC
attribute of image tag - Parameters passed using get METHOD
-
ltIMG SRC http//www.website-hit-counters.com/c
gi-bin/image.pl?URL51939-4076 ALT free
website hit countergt
29Web Page Counters
Counter Usefulness
- Number of hits per page
- Advertising rates
- Advertising for the counter company
Counter Display Decision
Some users offended by counters