370 likes | 528 Views
Introduction. The JavaScript Programming Language Applets The Java Programming Language Guest Books Web Page Counters Server-Side Includes. The JavaScript Programming Language. Introduction JavaScript and HTML Event Handlers Sample JavaScript Code. Scripting language
E N D
Introduction The JavaScript Programming Language Applets The Java Programming Language Guest Books Web Page Counters Server-Side Includes From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
The JavaScript Programming Language Introduction JavaScript and HTML Event Handlers Sample JavaScript Code From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Scripting language Not Java Statements usually embedded in HTML code Simple, interpreted programming language The JavaScript Programming Language Introduction From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Common uses: Alert boxes Color fades Dynamic-conversion form elements Information in status line Verify form input The JavaScript Programming Language Introduction From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
<SCRIPT></SCRIPT> JavaScript-enabled browser LANGUAGE SRC .js The JavaScript Programming Language JavaScript and HTML From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
<SCRIPT LANGUAGE = “JavaScript”> <!- - Begin hiding for browsers that cannot process JavaScript. Include JavaScript statements here. … Last JavaScript statement goes here. End hiding script. - -> </SCRIPT> The JavaScript Programming Language JavaScript and HTML From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
JavaScript and HTML <Html><Head><Title>onLoad Example</Title> <Script Language = “JavaScript”> <!- - Begin hiding for browsers that cannot support script. function ready(){ document.forms[0].elements[0].value=“Lets go!” } //Stop hiding script. --> </Script> </Head> <Body onLoad = “ready()”> <Form> <Input Type = “text” Value = “Loading…”> </Form></Body></Html> From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
onMouseOver and onMouseOut onMouseOver When you move mouse over item, action triggered onMouseOut When you move mouse out of area, action triggered The JavaScript Programming Language Event Handlers From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
onMouseOver and onMouseOut <A HREF = “ASSIGNMENTS/assign.html” onMouseOver = “loadimage(‘01’,’GRAPHICS/4ON.GIF’); status = ‘Assignments’; return true;” onMouseOut = “loadimage(‘01’, `GRAPHICS/4OFF.GIF’); status = ‘ ‘; return true;”> <IMG SRC = “GRAPHICS/4OFF.GIF” WIDTH = “42” HEIGHT = “42” NAME = “01” ALT = “Assignments” BORDER = “0”></A> The JavaScript Programming Language Event Handlers From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
The JavaScript Programming Language Event Handlers When user mouses over image: • Function call made to JavaScript routine loadimage() • Assignments displayed in status line • return true; indicates browser can return normally from processing JavaScript From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
The JavaScript Programming Language Event Handlers onClick and Alert Box <A HREF = “killface.html” onClick = “alert(‘Thanks for loading my page:Killface.’)”> Killface’s Page </A> From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
The JavaScript Programming Language Event Handlers From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Event Handlers onChange and Confirm Box, Prompt Box <Html><Head><Title>Confirm Box</Title> <Script Language = “JavaScript”> function question(yourname) { var name = yourname.value var theAnswer = confirm(“Are you really “ + name + “?”) (Or: var theAnswer = prompt(“What is your name”, “”)) } </Script></Head> <Body><Form> <Input Type = “text” Value = “Enter your name” onChange = “question(this)”> </Form></Body></Html> From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
<FORM ACTION = “mailto:killface@inspector.tuna.com” METHOD = “post”> <STRONG> Temperature Conversion Example Using JavaScript <BR> </STRONG> <P> </P> The JavaScript Programming Language Sample JavaScript Code From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
<INPUT TYPE = “text” NAME = “cels” VALUE = “0” SIZE = “3” MAXLENGTH = “3” onChange = “fahr.value = Math.round(10 * (1.8 * this.value + 32))/10;”> ° <STRONG>C</STRONG> <STRONG>equals</STRONG> The JavaScript Programming Language Sample JavaScript Code From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
<INPUT TYPE = “text” NAME = “fahr” VALUE = “32” SIZE = “3” MAXLENGTH = “3” onChange = “cels.value = Math.round(10 * (this.value - 32)/1.8)/10;”> ° <STRONG>F</STRONG> </FORM> The JavaScript Programming Language Sample JavaScript Code From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
NAME = “fahr” fahr.value Math.round() The JavaScript Programming Language Sample JavaScript Code From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Applets Introduction HTML Applet Tags Java-Enabled Browsers Sample Applets From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
“Little application” Primary features: Information is dynamic Can respond to input Program downloaded from Web server Runs locally Applets Introduction From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
<APPLET></APPLET> Attributes: ALIGN ALT CODE CODEBASE HEIGHT HSPACE NAME VSPACE WIDTH Applets HTML Applet Tags From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Browsers that are text-only or not Java-enabled ignore applet tags Display messages Applets Java-Enabled Browsers From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
<APPLET CODE = “HiMom.class” HEIGHT = “75” WIDTH = “125”> <PARAM NAME = “message” VALUE = “Hi Mom. How do you like my applet?”> </APPLET> Applets Sample Applets From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Applets Sample Applets From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
The Java Programming Language Introduction Java and Object-Oriented Programming From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Sun Microsystems Oak Java Virtual Machine The Java Programming Language Introduction From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Java supports object-oriented programming (OOP) Class Subclasses: children of parent class Applet class The Java Programming Language Java and Object-Oriented Programming From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Guest Books Standard Input Fields of a Guest Book Guest Book Dynamics Mailto Guest Books From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
E-mail address Message Name URL Guest Books Standard Input Fields of a Guest Book From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Created using form ACTION attribute specifies name of CGI script post METHOD sends parameters During sign in and updating: Guest fills out form Submits via SUBMIT button Parameters sent to CGI script Web server runs the CGI program World writeable file Guest Books Guest Book Dynamics From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
ACTION attribute specifies a mailto hyperlink Typical guest book: Form in which user signs in Collection of previous entries CGI script processes sign-ins * manually in mailto guest books Guest Books Mailto Guest Books From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Web Page Counters HTML Code for a Counter Counter Usefulness Counter Display Decision From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Absolute URL for CGI script as value of SRC attribute of image tag Parameters passed using get METHOD Web Page Counters HTML Code for a Counter <IMG SRC = “http://www.colt.com/cgibin/ counter?data=ellen.dat&style=1” ALIGN = “absmiddle” ALT = “counter” HEIGHT = “20” WIDTH = “70”> From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Number of hits per page Advertising rates Web Page Counters Counter Usefulness Counter Display Decision Some users offended by counters From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Server-Side Includes Common Inclusions Utilization From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Sends command to Web server from inside HTML document Another HTML document inside current one Counter Current time and date Last-modified date Random quote Random page Server-Side Includes Common Inclusions From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web
Syntax to run a program: <!-- #exec cgi = “/cgibin/script.cgi”--> Syntax to insert HTML document <!-- #include virtual = “insert.html”--> Server-Side Includes Utilization From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web