SlideShare a Scribd company logo
JavaScript: The Missing Manual Chapter 1: Writing Your First JavaScript Program Author: David S. McFarland | Publisher: O’Reilly Copyright 2010
Introducing Programming JavaScript is can be used to add intelligence to your Web pages JavaScript lets you make your Web pages more engaging and effective Copyright 2010
Introducing Programming As programming languages go, JavaScript is relatively friendly to nonprogrammers Still, JavaScript is more complex than either HTML or CSS and tends to be less intuitive to Web designers Copyright 2010
Introducing Programming Learning JavaScript’s syntax is like learning the vocabulary and grammar of another language Copyright 2010
Client Side vs. Server Side JavaScript is a  client-side  language it works inside of a Web browser (the client) you can view the source code along with HTML and CSS PHP (and other languages) are  server-side only works on the Web server cannot view the source code Copyright 2010
What is a Computer Program? A computer program is a series of steps completed in a designated order When you add JavaScript to a page you are writing a computer program actually, a lite version of a program called a  script Copyright 2010
Compiled vs. Scripting Languages Compiling  is the process of turning code a programmer writes into instructions that a computer can understand A scripting language, like JavaScript, uses an  interpreter  built into all Web browsers an  interpreter  converts the script into something a computer can understand Copyright 2010
How to Add JavaScript to a Page Anatomy of a Web browser: layout  or  rendering   engine the part of a Web browser that understands how to process HTML and CSS interpreter the part of a Web browser that understands how to process JavaScript Copyright 2010
How to Add JavaScript to a Page The  <script>  tag is regular old HTML it acts like a switch use the interpreter, not the rendering engine, to process the code that follows the  </script>  tag is the signal to switch back to using the rendering engine to process HTML and CSS Copyright 2010
How to Add JavaScript to a Page General guidelines #1: <script> placed inside <head> most of the time type  attribute needed for page validation <script> tags are placed after stylesheet information <link /> <style></style> <script type=“text/javascript”></script> Copyright 2010
How to Add JavaScript to a Page My First Internal JavaScript Page . . . <title>My First Internal JavaScript Page</title> <script type=&quot;text/javascript&quot;> alert(&quot;My first internal JavaScript page&quot;); </script> . . . first_internal.html Copyright 2010
How to Add JavaScript to a Page General guidelines #2: When creating an external JavaScript file: cut out all of the code  BETWEEN  the <script> tags, but  NOT INCLUDING  the <script> tags create a new text file with a .js extension use the  scr  attribute in the opening <script> tag to locate the external JavaScript file Copyright 2010
External JavaScript Files My First External JavaScript Page . . . <title>My First External JavaScript Page</title> <script type=&quot;text/javascript“ src=“first_external.js”> </script> . . . first_external.html Copyright 2010
How to Add JavaScript to a Page General guidelines #3: place JavaScript code in external files whenever possible <link /> <style></style> <script type=“text/javascript” src=“file_name.js”> </script> Copyright 2010
How to Add JavaScript to a Page General guidelines #4: place external JavaScript files in a folder (directory) called “scripts” the same way you’d place all images in an “images” directory or stylesheets in a “styles” directory <script type=“text/javascript”  ►  src=“scripts/file_name.js”></script> Copyright 2010
URL Types Three types of paths document-relative src=“scripts/first_external.js” root-relative src=“/scripts/first_external.js” absolute src=“http://gbabon.cdiaweb.com/  ► scripts/first_external.js” url_types.html Copyright 2010
Your First JavaScript  Program Assignment: Download file 1.1.html Add a JavaScript alert message that greets the visitor with “Hello world!”   1.1.html complete_1.1.html Copyright 2010
Writing Text on a Page Walk through: download file 1.2.html add a <script> tag set in the <body> below the <h1> tag set add the following command: document.write(‘<p>Hello world!</p>’);   1.2.html complete_1.2.html Copyright 2010
Writing Text on a Page General guidelines #5: <script> placed inside <head> most of the time Exceptions: when using a  document.write  statement to display an element on the page Copyright 2010
Attaching an External  JavaScript File Brief introduction to  libraries a  library  is a collection of JavaScript code, frequently written by others, and made available for you to use free of charge one increasing popular JavaScript library is called  jQuery Copyright 2010
Attaching an External  JavaScript File Walk through (jQuery striped tables): download file 1.3.html add <script> tags linking to jquery.js file add second set of <script> tags continued . . .   1.3.html complete_1.3.html Copyright 2010
Attaching an External  JavaScript File add the following jQuery code: $(document).ready(function() {   $(‘table.striped tr:even’).addClass(‘even’); });   1.3.html complete_1.3.html Copyright 2010
Tracking Down Errors Most Web browsers are set up to silently ignore JavaScript errors your code simply doesn’t work! no error message to bother the visitor Most Web browsers keep track of errors and record them in a separate window called a  JavaScript console Copyright 2010
JavaScript  Consoles Access the JavaScript console in Firefox: Tools  -> Error Console Access the JavaScript console in Safari: Safari -> Preferences -> Advanced -> Show Develop menu in menu bar Develop -> Show error console Copyright 2010
JavaScript  Consoles Access the JavaScript console in Internet Explorer: type in the URL getfirefox.com! Typical errors to look for: misspellings uneven pairs of ( ), { }, ‘ ’, “ ”, etc. Copyright 2010
JavaScript blah, blah, blah . . . Copyright 2010
Ad

More Related Content

What's hot (17)

Java script by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academy
actanimation
 
Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start)
Haim Michael
 
Java script programs
Java script programsJava script programs
Java script programs
ITz_1
 
Java Script
Java ScriptJava Script
Java Script
husbancom
 
Java script
Java scriptJava script
Java script
umesh patil
 
Introduction to Javascript programming
Introduction to Javascript programmingIntroduction to Javascript programming
Introduction to Javascript programming
Fulvio Corno
 
Java Script
Java ScriptJava Script
Java Script
Dr. SURBHI SAROHA
 
Java script
Java scriptJava script
Java script
Fajar Baskoro
 
Java script session 3
Java script session 3Java script session 3
Java script session 3
Saif Ullah Dar
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
Jaya Kumari
 
Java script
Java scriptJava script
Java script
ITz_1
 
Session vii(java scriptbasics)
Session vii(java scriptbasics)Session vii(java scriptbasics)
Session vii(java scriptbasics)
Shrijan Tiwari
 
Java script writing javascript
Java script writing javascriptJava script writing javascript
Java script writing javascript
Jesus Obenita Jr.
 
Introduction to html & css
Introduction to html & cssIntroduction to html & css
Introduction to html & css
sesharao puvvada
 
22 j query1
22 j query122 j query1
22 j query1
Fajar Baskoro
 
Test2
Test2Test2
Test2
Ermias Hailemicheal
 
Essential Javascript -- A Javascript &lt;b>Tutorial&lt;/b>
Essential Javascript -- A Javascript &lt;b>Tutorial&lt;/b>Essential Javascript -- A Javascript &lt;b>Tutorial&lt;/b>
Essential Javascript -- A Javascript &lt;b>Tutorial&lt;/b>
tutorialsruby
 
Java script by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academy
actanimation
 
Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start)
Haim Michael
 
Java script programs
Java script programsJava script programs
Java script programs
ITz_1
 
Introduction to Javascript programming
Introduction to Javascript programmingIntroduction to Javascript programming
Introduction to Javascript programming
Fulvio Corno
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
Jaya Kumari
 
Java script
Java scriptJava script
Java script
ITz_1
 
Session vii(java scriptbasics)
Session vii(java scriptbasics)Session vii(java scriptbasics)
Session vii(java scriptbasics)
Shrijan Tiwari
 
Java script writing javascript
Java script writing javascriptJava script writing javascript
Java script writing javascript
Jesus Obenita Jr.
 
Introduction to html & css
Introduction to html & cssIntroduction to html & css
Introduction to html & css
sesharao puvvada
 
Essential Javascript -- A Javascript &lt;b>Tutorial&lt;/b>
Essential Javascript -- A Javascript &lt;b>Tutorial&lt;/b>Essential Javascript -- A Javascript &lt;b>Tutorial&lt;/b>
Essential Javascript -- A Javascript &lt;b>Tutorial&lt;/b>
tutorialsruby
 

Similar to JavaScript Missing Manual, Ch. 1 (20)

JavaScript - Getting Started.pptx
JavaScript - Getting Started.pptxJavaScript - Getting Started.pptx
JavaScript - Getting Started.pptx
JonnJorellPunto
 
JS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTINGJS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTING
Arulkumar
 
1 Introduction to Drupal Web Development
1 Introduction to Drupal Web Development1 Introduction to Drupal Web Development
1 Introduction to Drupal Web Development
Wingston
 
Javascript
JavascriptJavascript
Javascript
padmaashree Arunachalem
 
High-Speed HTML5
High-Speed HTML5High-Speed HTML5
High-Speed HTML5
Peter Lubbers
 
Javascript
JavascriptJavascript
Javascript
Sushma M
 
Javascript
JavascriptJavascript
Javascript
Iblesoft
 
Before start
Before startBefore start
Before start
Medhat Dawoud
 
Javascript Intro 01
Javascript Intro 01Javascript Intro 01
Javascript Intro 01
vikram singh
 
Introduction to Java Scripting
Introduction to Java ScriptingIntroduction to Java Scripting
Introduction to Java Scripting
fantasticdigitaltools
 
Xhtml 2010
Xhtml 2010Xhtml 2010
Xhtml 2010
guest0f1e7f
 
Xhtml 2010
Xhtml 2010Xhtml 2010
Xhtml 2010
Cathie101
 
CIS 451: Introduction to ASP.NET
CIS 451: Introduction to ASP.NETCIS 451: Introduction to ASP.NET
CIS 451: Introduction to ASP.NET
webhostingguy
 
Javascript tutorial
Javascript tutorialJavascript tutorial
Javascript tutorial
Abhishek Kesharwani
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
DHTMLExtreme
 
HTML & JAVA Script
HTML & JAVA ScriptHTML & JAVA Script
HTML & JAVA Script
Nitesh Gupta
 
Introduction to Java script for web .pptx
Introduction to Java script for web .pptxIntroduction to Java script for web .pptx
Introduction to Java script for web .pptx
FahimMousa
 
Web II - 01 - Introduction to server-side development
Web II - 01 - Introduction to server-side developmentWeb II - 01 - Introduction to server-side development
Web II - 01 - Introduction to server-side development
Randy Connolly
 
Essential_Javascript_--_A_Javascript_Tutorial
Essential_Javascript_--_A_Javascript_TutorialEssential_Javascript_--_A_Javascript_Tutorial
Essential_Javascript_--_A_Javascript_Tutorial
tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
tutorialsruby
 
JavaScript - Getting Started.pptx
JavaScript - Getting Started.pptxJavaScript - Getting Started.pptx
JavaScript - Getting Started.pptx
JonnJorellPunto
 
JS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTINGJS BASICS JAVA SCRIPT SCRIPTING
JS BASICS JAVA SCRIPT SCRIPTING
Arulkumar
 
1 Introduction to Drupal Web Development
1 Introduction to Drupal Web Development1 Introduction to Drupal Web Development
1 Introduction to Drupal Web Development
Wingston
 
Javascript
JavascriptJavascript
Javascript
Sushma M
 
Javascript
JavascriptJavascript
Javascript
Iblesoft
 
Javascript Intro 01
Javascript Intro 01Javascript Intro 01
Javascript Intro 01
vikram singh
 
CIS 451: Introduction to ASP.NET
CIS 451: Introduction to ASP.NETCIS 451: Introduction to ASP.NET
CIS 451: Introduction to ASP.NET
webhostingguy
 
Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
DHTMLExtreme
 
HTML & JAVA Script
HTML & JAVA ScriptHTML & JAVA Script
HTML & JAVA Script
Nitesh Gupta
 
Introduction to Java script for web .pptx
Introduction to Java script for web .pptxIntroduction to Java script for web .pptx
Introduction to Java script for web .pptx
FahimMousa
 
Web II - 01 - Introduction to server-side development
Web II - 01 - Introduction to server-side developmentWeb II - 01 - Introduction to server-side development
Web II - 01 - Introduction to server-side development
Randy Connolly
 
Essential_Javascript_--_A_Javascript_Tutorial
Essential_Javascript_--_A_Javascript_TutorialEssential_Javascript_--_A_Javascript_Tutorial
Essential_Javascript_--_A_Javascript_Tutorial
tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
tutorialsruby
 
Ad

More from Gene Babon (20)

March Madness pool results | 2025
March Madness pool results | 2025March Madness pool results | 2025
March Madness pool results | 2025
Gene Babon
 
Job Search | Tropical Depressions | Bowling Alleys
Job Search | Tropical Depressions | Bowling AlleysJob Search | Tropical Depressions | Bowling Alleys
Job Search | Tropical Depressions | Bowling Alleys
Gene Babon
 
Tech Over Fifty Launch Meeting
Tech Over Fifty Launch MeetingTech Over Fifty Launch Meeting
Tech Over Fifty Launch Meeting
Gene Babon
 
Anatomy Virtual Self Study Group NEPHP 2018
Anatomy Virtual Self Study Group NEPHP 2018Anatomy Virtual Self Study Group NEPHP 2018
Anatomy Virtual Self Study Group NEPHP 2018
Gene Babon
 
Become a Front End Web Developer
Become a Front End Web DeveloperBecome a Front End Web Developer
Become a Front End Web Developer
Gene Babon
 
Navigating a Career in Web Technology
Navigating a Career in Web TechnologyNavigating a Career in Web Technology
Navigating a Career in Web Technology
Gene Babon
 
Info Session
Info SessionInfo Session
Info Session
Gene Babon
 
Info session
Info sessionInfo session
Info session
Gene Babon
 
Getting Things Done
Getting Things DoneGetting Things Done
Getting Things Done
Gene Babon
 
jQuery Mobile Hour 4
jQuery Mobile Hour 4jQuery Mobile Hour 4
jQuery Mobile Hour 4
Gene Babon
 
Lesson 17
Lesson 17Lesson 17
Lesson 17
Gene Babon
 
Lesson 18
Lesson 18Lesson 18
Lesson 18
Gene Babon
 
Lesson 17
Lesson 17Lesson 17
Lesson 17
Gene Babon
 
Lesson 16
Lesson 16Lesson 16
Lesson 16
Gene Babon
 
Lesson 15
Lesson 15Lesson 15
Lesson 15
Gene Babon
 
Lesson 11
Lesson 11Lesson 11
Lesson 11
Gene Babon
 
Lesson 10
Lesson 10Lesson 10
Lesson 10
Gene Babon
 
Lesson 09
Lesson 09Lesson 09
Lesson 09
Gene Babon
 
Lesson 05
Lesson 05Lesson 05
Lesson 05
Gene Babon
 
Lesson 04
Lesson 04Lesson 04
Lesson 04
Gene Babon
 
March Madness pool results | 2025
March Madness pool results | 2025March Madness pool results | 2025
March Madness pool results | 2025
Gene Babon
 
Job Search | Tropical Depressions | Bowling Alleys
Job Search | Tropical Depressions | Bowling AlleysJob Search | Tropical Depressions | Bowling Alleys
Job Search | Tropical Depressions | Bowling Alleys
Gene Babon
 
Tech Over Fifty Launch Meeting
Tech Over Fifty Launch MeetingTech Over Fifty Launch Meeting
Tech Over Fifty Launch Meeting
Gene Babon
 
Anatomy Virtual Self Study Group NEPHP 2018
Anatomy Virtual Self Study Group NEPHP 2018Anatomy Virtual Self Study Group NEPHP 2018
Anatomy Virtual Self Study Group NEPHP 2018
Gene Babon
 
Become a Front End Web Developer
Become a Front End Web DeveloperBecome a Front End Web Developer
Become a Front End Web Developer
Gene Babon
 
Navigating a Career in Web Technology
Navigating a Career in Web TechnologyNavigating a Career in Web Technology
Navigating a Career in Web Technology
Gene Babon
 
Getting Things Done
Getting Things DoneGetting Things Done
Getting Things Done
Gene Babon
 
jQuery Mobile Hour 4
jQuery Mobile Hour 4jQuery Mobile Hour 4
jQuery Mobile Hour 4
Gene Babon
 
Ad

Recently uploaded (20)

Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 

JavaScript Missing Manual, Ch. 1

  • 1. JavaScript: The Missing Manual Chapter 1: Writing Your First JavaScript Program Author: David S. McFarland | Publisher: O’Reilly Copyright 2010
  • 2. Introducing Programming JavaScript is can be used to add intelligence to your Web pages JavaScript lets you make your Web pages more engaging and effective Copyright 2010
  • 3. Introducing Programming As programming languages go, JavaScript is relatively friendly to nonprogrammers Still, JavaScript is more complex than either HTML or CSS and tends to be less intuitive to Web designers Copyright 2010
  • 4. Introducing Programming Learning JavaScript’s syntax is like learning the vocabulary and grammar of another language Copyright 2010
  • 5. Client Side vs. Server Side JavaScript is a client-side language it works inside of a Web browser (the client) you can view the source code along with HTML and CSS PHP (and other languages) are server-side only works on the Web server cannot view the source code Copyright 2010
  • 6. What is a Computer Program? A computer program is a series of steps completed in a designated order When you add JavaScript to a page you are writing a computer program actually, a lite version of a program called a script Copyright 2010
  • 7. Compiled vs. Scripting Languages Compiling is the process of turning code a programmer writes into instructions that a computer can understand A scripting language, like JavaScript, uses an interpreter built into all Web browsers an interpreter converts the script into something a computer can understand Copyright 2010
  • 8. How to Add JavaScript to a Page Anatomy of a Web browser: layout or rendering engine the part of a Web browser that understands how to process HTML and CSS interpreter the part of a Web browser that understands how to process JavaScript Copyright 2010
  • 9. How to Add JavaScript to a Page The <script> tag is regular old HTML it acts like a switch use the interpreter, not the rendering engine, to process the code that follows the </script> tag is the signal to switch back to using the rendering engine to process HTML and CSS Copyright 2010
  • 10. How to Add JavaScript to a Page General guidelines #1: <script> placed inside <head> most of the time type attribute needed for page validation <script> tags are placed after stylesheet information <link /> <style></style> <script type=“text/javascript”></script> Copyright 2010
  • 11. How to Add JavaScript to a Page My First Internal JavaScript Page . . . <title>My First Internal JavaScript Page</title> <script type=&quot;text/javascript&quot;> alert(&quot;My first internal JavaScript page&quot;); </script> . . . first_internal.html Copyright 2010
  • 12. How to Add JavaScript to a Page General guidelines #2: When creating an external JavaScript file: cut out all of the code BETWEEN the <script> tags, but NOT INCLUDING the <script> tags create a new text file with a .js extension use the scr attribute in the opening <script> tag to locate the external JavaScript file Copyright 2010
  • 13. External JavaScript Files My First External JavaScript Page . . . <title>My First External JavaScript Page</title> <script type=&quot;text/javascript“ src=“first_external.js”> </script> . . . first_external.html Copyright 2010
  • 14. How to Add JavaScript to a Page General guidelines #3: place JavaScript code in external files whenever possible <link /> <style></style> <script type=“text/javascript” src=“file_name.js”> </script> Copyright 2010
  • 15. How to Add JavaScript to a Page General guidelines #4: place external JavaScript files in a folder (directory) called “scripts” the same way you’d place all images in an “images” directory or stylesheets in a “styles” directory <script type=“text/javascript” ► src=“scripts/file_name.js”></script> Copyright 2010
  • 16. URL Types Three types of paths document-relative src=“scripts/first_external.js” root-relative src=“/scripts/first_external.js” absolute src=“http://gbabon.cdiaweb.com/ ► scripts/first_external.js” url_types.html Copyright 2010
  • 17. Your First JavaScript Program Assignment: Download file 1.1.html Add a JavaScript alert message that greets the visitor with “Hello world!” 1.1.html complete_1.1.html Copyright 2010
  • 18. Writing Text on a Page Walk through: download file 1.2.html add a <script> tag set in the <body> below the <h1> tag set add the following command: document.write(‘<p>Hello world!</p>’); 1.2.html complete_1.2.html Copyright 2010
  • 19. Writing Text on a Page General guidelines #5: <script> placed inside <head> most of the time Exceptions: when using a document.write statement to display an element on the page Copyright 2010
  • 20. Attaching an External JavaScript File Brief introduction to libraries a library is a collection of JavaScript code, frequently written by others, and made available for you to use free of charge one increasing popular JavaScript library is called jQuery Copyright 2010
  • 21. Attaching an External JavaScript File Walk through (jQuery striped tables): download file 1.3.html add <script> tags linking to jquery.js file add second set of <script> tags continued . . . 1.3.html complete_1.3.html Copyright 2010
  • 22. Attaching an External JavaScript File add the following jQuery code: $(document).ready(function() { $(‘table.striped tr:even’).addClass(‘even’); }); 1.3.html complete_1.3.html Copyright 2010
  • 23. Tracking Down Errors Most Web browsers are set up to silently ignore JavaScript errors your code simply doesn’t work! no error message to bother the visitor Most Web browsers keep track of errors and record them in a separate window called a JavaScript console Copyright 2010
  • 24. JavaScript Consoles Access the JavaScript console in Firefox: Tools -> Error Console Access the JavaScript console in Safari: Safari -> Preferences -> Advanced -> Show Develop menu in menu bar Develop -> Show error console Copyright 2010
  • 25. JavaScript Consoles Access the JavaScript console in Internet Explorer: type in the URL getfirefox.com! Typical errors to look for: misspellings uneven pairs of ( ), { }, ‘ ’, “ ”, etc. Copyright 2010
  • 26. JavaScript blah, blah, blah . . . Copyright 2010