SlideShare a Scribd company logo
CIS 233
JavaScript Basics
What is JavaScript?
JavaScript is a scripting language
designed for Web pages by Netscape.
CIS 233
• JavaScript ≠ Java
• Developed by Netscape
• Purpose: to Create Dynamic websites
• Widely Used
CIS 233
Why Use JavaScript?
• JavaScript enhances Web pages with dynamic and
interactive features.
• JavaScript runs in client software.
• JavaScript 1.3 works with version 4.0 browsers.
CIS 233
What Can JavaScript Do?
• Common JavaScript tasks can replace server-
side scripting.
• JavaScript enables shopping carts, form
validation, calculations, special graphic and
text effects, image swapping, image mapping,
clocks, and more.
CIS 233
• Client-side programming
• recall: HTML is good for developing static pages
• 􀂃 can specify text/image layout, presentation, links, …
• 􀂃 Web page looks the same each time it is accessed
• 􀂃 in order to develop interactive/reactive pages, must
integrate programming
• client-side programming
CIS 233
• 􀂃 programs are written in a separate programming
language
• e.g., JavaScript, JScript, VBScript
• 􀂃 programs are embedded in the HTML of a Web page,
with tags to identify the
• program component
• e.g., <script type="text/javascript"> … </script>
• 􀂃 the browser executes the program as it loads the
page, integrating the dynamic
• output of the program with the static content of HTML
CIS 233
JavaScript Syntax.
• Unlike HTML, JavaScript is case sensitive.
• Dot Syntax is used to combine terms.
• e.g., document.write("Hello World")
• Certain characters and terms are reserved.
• JavaScript is simple text (ASCII).
CIS 233
JavaScript Terminology.
• JavaScript uses specialized terminology.
• Understanding JavaScript terms is
fundamental to understanding the script.
• Objects, Properties, Methods, Events, Functions,
Values, Variables, Expressions, Operators.
CIS 233
Objects
• Objects refers to windows, documents,
images, tables, forms, buttons or links, etc.
• Objects should be named.
• Objects have properties that act as modifiers.
CIS 233
Properties
• Properties are object attributes.
• Object properties are defined by using the
object's name, a period, and the property
name.
• e.g., background color is expressed by:
document.bgcolor .
• document is the object.
• bgcolor is the property.
CIS 233
Methods
• Methods are actions applied to particular
objects. Methods are what objects can do.
• e.g., document.write(”Hello World")
• document is the object.
• write is the method.
CIS 233
Events
• Events associate an object with an action.
• e.g., the OnMouseover event handler action can
change an image.
• e.g., the onSubmit event handler sends a form.
• User actions trigger events.
CIS 233
Functions
• Functions are named statements that
performs tasks.
• e.g., function doWhatever () {statement here}
• The curly braces contain the statements of the
function.
• JavaScript has built-in functions, and you can
write your own.
CIS 233
Function
<script langauge="JavaScript">
<!-- hide me
function announceTime( ) {
//get the date, the hour, minutes, and seconds
var the_date = new Date();
var the_hour = the_date.getHours();
var the_minute = the_date.getMinutes();
var the_second = the_date.getSeconds();
//put together the string and alert with it
var the_time = the_hour + ":" + the_minute + ":" + the_second;
alert("The time is now: " + the_time); }
// show me -->
</script> </head> <body> ... </body> </html>
CIS 233
Values
• Values are bits of information.
• Values types and some examples include:
• Number: 1, 2, 3, etc.
• String: characters enclosed in quotes.
• Boolean: true or false.
• Object: image, form
• Function: validate, doWhatever
CIS 233
Variables
• Variables contain values and use the equal
sign to specify their value.
• Variables are created by declaration using
the var command with or without an initial
value state.
• e.g. var month;
• e.g. var month = April;
CIS 233
Variables
<script language=“JavaScript”>
<!-- definition of variables
var num_car= 25;
var passenger_per_car= 3;
//calculation of total number of people
var total_passenger= num_car * passenger_per_car
Alert(total_passenger);
// end of script -->
</script>
www.artsci.wustl.edu/~hmliaw/Test-Variable.htm
CIS 233
Expressions
• Expressions are commands that assign
values to variables.
• Expressions always use an assignment
operator, such as the equals sign.
• e.g., var month = May; is an expression.
• Expressions end with a semicolon.
CIS 233
Operators
• Operators are used to handle variables.
• Types of operators with examples:
• Arithmetic operators, such as plus.
• Comparisons operators, such as equals.
• Logical operators, such as and.
• Control operators, such as if.
• Assignment and String operators.
CIS 233
Methods of Using JavaScript.
1. JavaScripts can reside in a separate page.
2. JavaScript can be embedded in HTML
documents -- in the <head>, in the
<body>, or in both.
3. JavaScript object attributes can be placed
in HTML element tags.
e.g., <body onLoad="alert('WELCOME')">
CIS 233
<html>
<head>
<title>JavaScript Page</title>
<script LANGUAGE=“JavaScript”>
<!-- actual JavaScript follows below
alert (“Welcome to the Test Site!”);
// ending the script -->
</script>
</head>
CIS 233
1. Using Separate JavaScript Files.
• Linking can be advantageous if many pages use
the same script.
• Use the source element to link to the script file.
<script src="myjavascript.js”
language="JavaScript1.2”
type="text/javascript">
</script>
CIS 233
2. Embedding JavaScript in HTML.
• When specifying a script only the tags
<script> and </script> are essential, but
complete specification is recommended:
<script language="javascript”
type="text/javascript">
<!-- Begin hiding
window.location=”index.html"
// End hiding script-->
</script>
CIS 233
Using Comment Tags
• HTML comment tags should bracket any script.
• The <!-- script here --> tags hide scripts
in HTML and prevent scripts from displaying in
browsers that do not interpret JavaScript.
• Double slashes // are the signal characters
for a JavaScript single-line comment.
CIS 233
3. Using JavaScript in HTML Tags.
• Event handlers like onMouseover are a perfect
example of an easy to add tag script.
<a href=”index.html”
onMouseover="document.logo.src='js2.gif'"
onMouseout="document.logo.src='js.gif'">
<img src="js.gif" name="logo">
</a>
CIS 233
Creating an Alert Message
• The following script in the <body> tag uses the
onLoad event to display an Alert window
• The message is specified within parenthesis.
<body onLoad="alert('WELCOME. Enjoy
your visit. Your feedback can improve
cyberspace. Please let me know if you
detect any problems. Thank you.')">
Ad

More Related Content

What's hot (20)

Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
abhilashagupta
 
Java script
Java scriptJava script
Java script
Sadeek Mohammed
 
Js ppt
Js pptJs ppt
Js ppt
Rakhi Thota
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
Webtech Learning
 
Java script
Java scriptJava script
Java script
Abhishek Kesharwani
 
Html ppt
Html pptHtml ppt
Html ppt
santosh lamba
 
Html forms
Html formsHtml forms
Html forms
Himanshu Pathak
 
Html forms
Html formsHtml forms
Html forms
Er. Nawaraj Bhandari
 
Html Slide Part-1
Html Slide Part-1Html Slide Part-1
Html Slide Part-1
AAKASH KUMAR
 
Tags in html
Tags in htmlTags in html
Tags in html
Balakumaran Arunachalam
 
Java script array
Java script arrayJava script array
Java script array
chauhankapil
 
Javascript
JavascriptJavascript
Javascript
mussawir20
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
HTML5
HTML5HTML5
HTML5
Hatem Mahmoud
 
Css Ppt
Css PptCss Ppt
Css Ppt
Hema Prasanth
 
Web html table tags
Web html  table tagsWeb html  table tags
Web html table tags
Kainat Ilyas
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
Amit Tyagi
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
ShahDhruv21
 
Html frames
Html framesHtml frames
Html frames
eShikshak
 

Similar to javascript-basics.ppt (20)

Javascript
JavascriptJavascript
Javascript
Mozxai
 
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulationCS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
amrashbhanuabdul
 
Learn javascript easy steps
Learn javascript easy stepsLearn javascript easy steps
Learn javascript easy steps
prince Loffar
 
Introduction to JavaScript, functions, DOM
Introduction to JavaScript, functions, DOMIntroduction to JavaScript, functions, DOM
Introduction to JavaScript, functions, DOM
LikhithaBrunda
 
WT UNIT 2 presentation :client side technologies JavaScript And Dom
WT UNIT 2 presentation :client side technologies JavaScript And DomWT UNIT 2 presentation :client side technologies JavaScript And Dom
WT UNIT 2 presentation :client side technologies JavaScript And Dom
SrushtiGhise
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Marlon Jamera
 
Final Java-script.pptx
Final Java-script.pptxFinal Java-script.pptx
Final Java-script.pptx
AlkanthiSomesh
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
koppenolski
 
JS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTINGJS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTING
Arulkumar
 
Unit 4(it workshop)
Unit 4(it workshop)Unit 4(it workshop)
Unit 4(it workshop)
Dr.Lokesh Gagnani
 
Java script Learn Easy
Java script Learn Easy Java script Learn Easy
Java script Learn Easy
prince Loffar
 
INTRO TO JAVASCRIPT basic to adcance.ppt
INTRO TO JAVASCRIPT basic to adcance.pptINTRO TO JAVASCRIPT basic to adcance.ppt
INTRO TO JAVASCRIPT basic to adcance.ppt
testvarun21
 
Internet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptxInternet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptx
ssuser92282c
 
Java script
Java scriptJava script
Java script
Sukrit Gupta
 
Java script
Java scriptJava script
Java script
Jay Patel
 
Overview of PHP and MYSQL
Overview of PHP and MYSQLOverview of PHP and MYSQL
Overview of PHP and MYSQL
Deblina Chowdhury
 
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTHSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
AAFREEN SHAIKH
 
Easy javascript
Easy javascriptEasy javascript
Easy javascript
Bui Kiet
 
Java script202
Java script202Java script202
Java script202
Wasiq Zia
 
JavaScript
JavaScriptJavaScript
JavaScript
tutorialsruby
 
Javascript
JavascriptJavascript
Javascript
Mozxai
 
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulationCS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
amrashbhanuabdul
 
Learn javascript easy steps
Learn javascript easy stepsLearn javascript easy steps
Learn javascript easy steps
prince Loffar
 
Introduction to JavaScript, functions, DOM
Introduction to JavaScript, functions, DOMIntroduction to JavaScript, functions, DOM
Introduction to JavaScript, functions, DOM
LikhithaBrunda
 
WT UNIT 2 presentation :client side technologies JavaScript And Dom
WT UNIT 2 presentation :client side technologies JavaScript And DomWT UNIT 2 presentation :client side technologies JavaScript And Dom
WT UNIT 2 presentation :client side technologies JavaScript And Dom
SrushtiGhise
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Marlon Jamera
 
Final Java-script.pptx
Final Java-script.pptxFinal Java-script.pptx
Final Java-script.pptx
AlkanthiSomesh
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
koppenolski
 
JS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTINGJS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTING
Arulkumar
 
Java script Learn Easy
Java script Learn Easy Java script Learn Easy
Java script Learn Easy
prince Loffar
 
INTRO TO JAVASCRIPT basic to adcance.ppt
INTRO TO JAVASCRIPT basic to adcance.pptINTRO TO JAVASCRIPT basic to adcance.ppt
INTRO TO JAVASCRIPT basic to adcance.ppt
testvarun21
 
Internet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptxInternet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptx
ssuser92282c
 
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPTHSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
HSC INFORMATION TECHNOLOGY CHAPTER 3 ADVANCED JAVASCRIPT
AAFREEN SHAIKH
 
Easy javascript
Easy javascriptEasy javascript
Easy javascript
Bui Kiet
 
Java script202
Java script202Java script202
Java script202
Wasiq Zia
 
Ad

More from ahmadfaisal744721 (20)

Introduction+to+AngularJS+with+logo+from+digital+ocean.pdf
Introduction+to+AngularJS+with+logo+from+digital+ocean.pdfIntroduction+to+AngularJS+with+logo+from+digital+ocean.pdf
Introduction+to+AngularJS+with+logo+from+digital+ocean.pdf
ahmadfaisal744721
 
Intoduction to Graph.pptx
Intoduction to Graph.pptxIntoduction to Graph.pptx
Intoduction to Graph.pptx
ahmadfaisal744721
 
Introduction to Android.ppt
Introduction to Android.pptIntroduction to Android.ppt
Introduction to Android.ppt
ahmadfaisal744721
 
Topics-Ch4Ch5.ppt
Topics-Ch4Ch5.pptTopics-Ch4Ch5.ppt
Topics-Ch4Ch5.ppt
ahmadfaisal744721
 
db design and maintenance part 1.pptx
db design and maintenance part 1.pptxdb design and maintenance part 1.pptx
db design and maintenance part 1.pptx
ahmadfaisal744721
 
Chapter 4v4 Network protocols and standards 2.pptx
Chapter 4v4  Network protocols and standards 2.pptxChapter 4v4  Network protocols and standards 2.pptx
Chapter 4v4 Network protocols and standards 2.pptx
ahmadfaisal744721
 
Chapter 4v4 Network protocols and standards 1.pptx
Chapter 4v4  Network protocols and standards 1.pptxChapter 4v4  Network protocols and standards 1.pptx
Chapter 4v4 Network protocols and standards 1.pptx
ahmadfaisal744721
 
Chapter 3v3 Mobile communication systems.pptx
Chapter 3v3 Mobile communication systems.pptxChapter 3v3 Mobile communication systems.pptx
Chapter 3v3 Mobile communication systems.pptx
ahmadfaisal744721
 
Chapter 2v4 Pervasive Computing systems, design and infrastructure 2.pptx
Chapter 2v4 Pervasive Computing systems, design and infrastructure 2.pptxChapter 2v4 Pervasive Computing systems, design and infrastructure 2.pptx
Chapter 2v4 Pervasive Computing systems, design and infrastructure 2.pptx
ahmadfaisal744721
 
Chapter 2v4 Pervasive Computing systems, design and infrastructure 1.pptx
Chapter 2v4 Pervasive Computing systems, design and infrastructure 1.pptxChapter 2v4 Pervasive Computing systems, design and infrastructure 1.pptx
Chapter 2v4 Pervasive Computing systems, design and infrastructure 1.pptx
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 9.ppt
Sec.0a--Intro to pervasive computing 9.pptSec.0a--Intro to pervasive computing 9.ppt
Sec.0a--Intro to pervasive computing 9.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 8.ppt
Sec.0a--Intro to pervasive computing 8.pptSec.0a--Intro to pervasive computing 8.ppt
Sec.0a--Intro to pervasive computing 8.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 7.ppt
Sec.0a--Intro to pervasive computing 7.pptSec.0a--Intro to pervasive computing 7.ppt
Sec.0a--Intro to pervasive computing 7.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 6.ppt
Sec.0a--Intro to pervasive computing 6.pptSec.0a--Intro to pervasive computing 6.ppt
Sec.0a--Intro to pervasive computing 6.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 5.ppt
Sec.0a--Intro to pervasive computing 5.pptSec.0a--Intro to pervasive computing 5.ppt
Sec.0a--Intro to pervasive computing 5.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 4.ppt
Sec.0a--Intro to pervasive computing 4.pptSec.0a--Intro to pervasive computing 4.ppt
Sec.0a--Intro to pervasive computing 4.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 3.ppt
Sec.0a--Intro to pervasive computing 3.pptSec.0a--Intro to pervasive computing 3.ppt
Sec.0a--Intro to pervasive computing 3.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 2.ppt
Sec.0a--Intro to pervasive computing 2.pptSec.0a--Intro to pervasive computing 2.ppt
Sec.0a--Intro to pervasive computing 2.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 1.ppt
Sec.0a--Intro to pervasive computing 1.pptSec.0a--Intro to pervasive computing 1.ppt
Sec.0a--Intro to pervasive computing 1.ppt
ahmadfaisal744721
 
write no image.pptx
write no image.pptxwrite no image.pptx
write no image.pptx
ahmadfaisal744721
 
Introduction+to+AngularJS+with+logo+from+digital+ocean.pdf
Introduction+to+AngularJS+with+logo+from+digital+ocean.pdfIntroduction+to+AngularJS+with+logo+from+digital+ocean.pdf
Introduction+to+AngularJS+with+logo+from+digital+ocean.pdf
ahmadfaisal744721
 
db design and maintenance part 1.pptx
db design and maintenance part 1.pptxdb design and maintenance part 1.pptx
db design and maintenance part 1.pptx
ahmadfaisal744721
 
Chapter 4v4 Network protocols and standards 2.pptx
Chapter 4v4  Network protocols and standards 2.pptxChapter 4v4  Network protocols and standards 2.pptx
Chapter 4v4 Network protocols and standards 2.pptx
ahmadfaisal744721
 
Chapter 4v4 Network protocols and standards 1.pptx
Chapter 4v4  Network protocols and standards 1.pptxChapter 4v4  Network protocols and standards 1.pptx
Chapter 4v4 Network protocols and standards 1.pptx
ahmadfaisal744721
 
Chapter 3v3 Mobile communication systems.pptx
Chapter 3v3 Mobile communication systems.pptxChapter 3v3 Mobile communication systems.pptx
Chapter 3v3 Mobile communication systems.pptx
ahmadfaisal744721
 
Chapter 2v4 Pervasive Computing systems, design and infrastructure 2.pptx
Chapter 2v4 Pervasive Computing systems, design and infrastructure 2.pptxChapter 2v4 Pervasive Computing systems, design and infrastructure 2.pptx
Chapter 2v4 Pervasive Computing systems, design and infrastructure 2.pptx
ahmadfaisal744721
 
Chapter 2v4 Pervasive Computing systems, design and infrastructure 1.pptx
Chapter 2v4 Pervasive Computing systems, design and infrastructure 1.pptxChapter 2v4 Pervasive Computing systems, design and infrastructure 1.pptx
Chapter 2v4 Pervasive Computing systems, design and infrastructure 1.pptx
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 9.ppt
Sec.0a--Intro to pervasive computing 9.pptSec.0a--Intro to pervasive computing 9.ppt
Sec.0a--Intro to pervasive computing 9.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 8.ppt
Sec.0a--Intro to pervasive computing 8.pptSec.0a--Intro to pervasive computing 8.ppt
Sec.0a--Intro to pervasive computing 8.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 7.ppt
Sec.0a--Intro to pervasive computing 7.pptSec.0a--Intro to pervasive computing 7.ppt
Sec.0a--Intro to pervasive computing 7.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 6.ppt
Sec.0a--Intro to pervasive computing 6.pptSec.0a--Intro to pervasive computing 6.ppt
Sec.0a--Intro to pervasive computing 6.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 5.ppt
Sec.0a--Intro to pervasive computing 5.pptSec.0a--Intro to pervasive computing 5.ppt
Sec.0a--Intro to pervasive computing 5.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 4.ppt
Sec.0a--Intro to pervasive computing 4.pptSec.0a--Intro to pervasive computing 4.ppt
Sec.0a--Intro to pervasive computing 4.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 3.ppt
Sec.0a--Intro to pervasive computing 3.pptSec.0a--Intro to pervasive computing 3.ppt
Sec.0a--Intro to pervasive computing 3.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 2.ppt
Sec.0a--Intro to pervasive computing 2.pptSec.0a--Intro to pervasive computing 2.ppt
Sec.0a--Intro to pervasive computing 2.ppt
ahmadfaisal744721
 
Sec.0a--Intro to pervasive computing 1.ppt
Sec.0a--Intro to pervasive computing 1.pptSec.0a--Intro to pervasive computing 1.ppt
Sec.0a--Intro to pervasive computing 1.ppt
ahmadfaisal744721
 
Ad

Recently uploaded (20)

Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 

javascript-basics.ppt

  • 1. CIS 233 JavaScript Basics What is JavaScript? JavaScript is a scripting language designed for Web pages by Netscape.
  • 2. CIS 233 • JavaScript ≠ Java • Developed by Netscape • Purpose: to Create Dynamic websites • Widely Used
  • 3. CIS 233 Why Use JavaScript? • JavaScript enhances Web pages with dynamic and interactive features. • JavaScript runs in client software. • JavaScript 1.3 works with version 4.0 browsers.
  • 4. CIS 233 What Can JavaScript Do? • Common JavaScript tasks can replace server- side scripting. • JavaScript enables shopping carts, form validation, calculations, special graphic and text effects, image swapping, image mapping, clocks, and more.
  • 5. CIS 233 • Client-side programming • recall: HTML is good for developing static pages • 􀂃 can specify text/image layout, presentation, links, … • 􀂃 Web page looks the same each time it is accessed • 􀂃 in order to develop interactive/reactive pages, must integrate programming • client-side programming
  • 6. CIS 233 • 􀂃 programs are written in a separate programming language • e.g., JavaScript, JScript, VBScript • 􀂃 programs are embedded in the HTML of a Web page, with tags to identify the • program component • e.g., <script type="text/javascript"> … </script> • 􀂃 the browser executes the program as it loads the page, integrating the dynamic • output of the program with the static content of HTML
  • 7. CIS 233 JavaScript Syntax. • Unlike HTML, JavaScript is case sensitive. • Dot Syntax is used to combine terms. • e.g., document.write("Hello World") • Certain characters and terms are reserved. • JavaScript is simple text (ASCII).
  • 8. CIS 233 JavaScript Terminology. • JavaScript uses specialized terminology. • Understanding JavaScript terms is fundamental to understanding the script. • Objects, Properties, Methods, Events, Functions, Values, Variables, Expressions, Operators.
  • 9. CIS 233 Objects • Objects refers to windows, documents, images, tables, forms, buttons or links, etc. • Objects should be named. • Objects have properties that act as modifiers.
  • 10. CIS 233 Properties • Properties are object attributes. • Object properties are defined by using the object's name, a period, and the property name. • e.g., background color is expressed by: document.bgcolor . • document is the object. • bgcolor is the property.
  • 11. CIS 233 Methods • Methods are actions applied to particular objects. Methods are what objects can do. • e.g., document.write(”Hello World") • document is the object. • write is the method.
  • 12. CIS 233 Events • Events associate an object with an action. • e.g., the OnMouseover event handler action can change an image. • e.g., the onSubmit event handler sends a form. • User actions trigger events.
  • 13. CIS 233 Functions • Functions are named statements that performs tasks. • e.g., function doWhatever () {statement here} • The curly braces contain the statements of the function. • JavaScript has built-in functions, and you can write your own.
  • 14. CIS 233 Function <script langauge="JavaScript"> <!-- hide me function announceTime( ) { //get the date, the hour, minutes, and seconds var the_date = new Date(); var the_hour = the_date.getHours(); var the_minute = the_date.getMinutes(); var the_second = the_date.getSeconds(); //put together the string and alert with it var the_time = the_hour + ":" + the_minute + ":" + the_second; alert("The time is now: " + the_time); } // show me --> </script> </head> <body> ... </body> </html>
  • 15. CIS 233 Values • Values are bits of information. • Values types and some examples include: • Number: 1, 2, 3, etc. • String: characters enclosed in quotes. • Boolean: true or false. • Object: image, form • Function: validate, doWhatever
  • 16. CIS 233 Variables • Variables contain values and use the equal sign to specify their value. • Variables are created by declaration using the var command with or without an initial value state. • e.g. var month; • e.g. var month = April;
  • 17. CIS 233 Variables <script language=“JavaScript”> <!-- definition of variables var num_car= 25; var passenger_per_car= 3; //calculation of total number of people var total_passenger= num_car * passenger_per_car Alert(total_passenger); // end of script --> </script> www.artsci.wustl.edu/~hmliaw/Test-Variable.htm
  • 18. CIS 233 Expressions • Expressions are commands that assign values to variables. • Expressions always use an assignment operator, such as the equals sign. • e.g., var month = May; is an expression. • Expressions end with a semicolon.
  • 19. CIS 233 Operators • Operators are used to handle variables. • Types of operators with examples: • Arithmetic operators, such as plus. • Comparisons operators, such as equals. • Logical operators, such as and. • Control operators, such as if. • Assignment and String operators.
  • 20. CIS 233 Methods of Using JavaScript. 1. JavaScripts can reside in a separate page. 2. JavaScript can be embedded in HTML documents -- in the <head>, in the <body>, or in both. 3. JavaScript object attributes can be placed in HTML element tags. e.g., <body onLoad="alert('WELCOME')">
  • 21. CIS 233 <html> <head> <title>JavaScript Page</title> <script LANGUAGE=“JavaScript”> <!-- actual JavaScript follows below alert (“Welcome to the Test Site!”); // ending the script --> </script> </head>
  • 22. CIS 233 1. Using Separate JavaScript Files. • Linking can be advantageous if many pages use the same script. • Use the source element to link to the script file. <script src="myjavascript.js” language="JavaScript1.2” type="text/javascript"> </script>
  • 23. CIS 233 2. Embedding JavaScript in HTML. • When specifying a script only the tags <script> and </script> are essential, but complete specification is recommended: <script language="javascript” type="text/javascript"> <!-- Begin hiding window.location=”index.html" // End hiding script--> </script>
  • 24. CIS 233 Using Comment Tags • HTML comment tags should bracket any script. • The <!-- script here --> tags hide scripts in HTML and prevent scripts from displaying in browsers that do not interpret JavaScript. • Double slashes // are the signal characters for a JavaScript single-line comment.
  • 25. CIS 233 3. Using JavaScript in HTML Tags. • Event handlers like onMouseover are a perfect example of an easy to add tag script. <a href=”index.html” onMouseover="document.logo.src='js2.gif'" onMouseout="document.logo.src='js.gif'"> <img src="js.gif" name="logo"> </a>
  • 26. CIS 233 Creating an Alert Message • The following script in the <body> tag uses the onLoad event to display an Alert window • The message is specified within parenthesis. <body onLoad="alert('WELCOME. Enjoy your visit. Your feedback can improve cyberspace. Please let me know if you detect any problems. Thank you.')">

Editor's Notes

  • #22: Be sure you can explain this sufficiently!