introduction to javascript. introduction what is it? how does it work? what is java? learning...
DESCRIPTION
What is JavaScript? Browsers have limited functionality Text, images, tables, frames JavaScript allows for interactivity Browser/page manipulation Reacting to user actions A type of programming language Easy to learn Developed by Netscape Now a standard exists – standards/ECMA-262.HTMTRANSCRIPT
![Page 1: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/1.jpg)
Introduction to JavaScript
![Page 2: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/2.jpg)
IntroductionWhat is it?How does it work?What is Java?Learning JavaScript
JavaScript Statements JavaScript and HTML forms
![Page 3: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/3.jpg)
What is JavaScript?Browsers have limited functionality
Text, images, tables, framesJavaScript allows for interactivityBrowser/page manipulation
Reacting to user actionsA type of programming language
Easy to learn Developed by Netscape Now a standard exists – www.ecma-international.org/publications/standards/ECMA-262.HTM
![Page 4: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/4.jpg)
JavaScript Allows InteractivityImprove appearance
Especially graphics Visual feedback
Site navigationPerform calculationsValidation of inputOther technologies
javascript.internet.com
![Page 5: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/5.jpg)
How Does It Work?Embedded within HTML page
View sourceExecutes on client
Fast, no connection needed once loadedSimple programming statements combined with
HTML tagsInterpreted (not compiled)
No special tools required
![Page 6: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/6.jpg)
What is Java?Totally differentA full programming languageMuch harder!A compiled languageIndependent of the webSometimes used together
![Page 7: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/7.jpg)
Learning JavaScriptSpecial syntax to learnLearn the basics and then use other people's
(lots of free sites)Write it in a text editor, view results in browserYou need to revise your HTML You need patience and good eyesight!
![Page 8: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/8.jpg)
JavaScript Statements<html><head><title>My Page</title></head><body><script language="JavaScript">
document.write('This is my first JavaScript Page');
</script></body></html>
Note the symbol for line continuation
![Page 9: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/9.jpg)
JavaScript Statements<html><head><title>My Page</title></head><body><script language=“JavaScript">
document.write('<h1>This is my first JavaScript Page</h1>');
</script></body></html>
HTML writteninside JavaScript
![Page 10: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/10.jpg)
JavaScript Statements<html><head><title>My Page</title></head><body><p><a href="myfile.html">My Page</a><br /><a href="myfile.html"onMouseover="window.alert('Hello');">My Page</A></p></body></html>
JavaScript writteninside HTML
An Event
![Page 11: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/11.jpg)
Example Statements<script language="JavaScript">window.prompt('Enter your name:','');</script>
<form><input type="button" Value="Press" onClick="window.alert('Hello');">
</form>
Another event
Note quotes: " and '
![Page 12: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/12.jpg)
HTML Forms and JavaScriptJavaScript is very good at processing user input
in the web browserHTML <form> elements receive inputForms and form elements have unique names
Each unique element can be identified Uses JavaScript Document Object Model (DOM)
![Page 13: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/13.jpg)
Naming Form Elements in HTML
<form name="addressform">Name: <input name="yourname"><br />Phone: <input name="phone"><br />Email: <input name="email"><br /></form>
![Page 14: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/14.jpg)
Forms and JavaScriptdocument.formname.elementname.valueThus:
document.addressform.yourname.valuedocument.addressform.phone.valuedocument.addressform.email.value
![Page 15: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/15.jpg)
Using Form DataPersonalising an alert box
<form name="alertform">Enter your name:<input type="text" name="yourname"><input type="button" value= "Go" onClick="window.alert('Hello ' + document.alertform.yourname.value);">
</form>
![Page 16: Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms](https://reader036.vdocuments.net/reader036/viewer/2022082622/5a4d1bbb7f8b9ab0599d0d17/html5/thumbnails/16.jpg)
TipsCheck your statements are on one lineCheck your " and ' quotes matchTake care with capitalisationLay it out neatly - use tabsRemember in the workbook denotes a
continuing lineBe patient
Presentation slides adapted from scom.hud.ac.uk/scomsjw/Web%20Authoring%20Module/Lecture%20Slides/ introjs.ppt