SlideShare a Scribd company logo
1 of 13
Download to read offline
JavaScript
Istruzioni per l’uso
ugo.rinaldi@gmail.com
JavaScript is one of the 3 languages all web
developers must learn:
1. HTML to define the content of web pages
2. CSS to specify the layout of web pages
3. JavaScript to program the behavior of web
pages
2
<script> nella HEAD
JavaScript can be placed in the <body> and the <head> sections
of an HTML page.
<head>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</head>
<body>
<h1>My Web Page</h1>
<p id="demo">A Paragraph</p>
<button type="button" onclick="myFunction()">Try it</button>
</body>
3
<script> Nel BODY
 <body>
<h1>MyWeb Page</h1>
<p id="demo">A Paragraph</p>
<button type="button" onclick="myFunction()">Try it</button>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</body>
4
External JavaScript
 Placing JavaScripts in external files has some advantages:
 It separates HTML and code
 It makes HTML and JavaScript easier to read and maintain
 Cached JavaScript files can speed up page loads
 <!DOCTYPE html>
<html>
<body>
<script src="myScript.js"></script>
</body>
</html>
5
Output
 JavaScript can "display" data in different ways:
• Writing into an alert box, using window.alert().
• Writing into the HTML output using document.write().
• Writing into an HTML element, using innerHTML.
• Writing into the browser console, using console.log()
• Esempi:
• alert(5 + 6);
• <button onclick="document.write(5 + 6)">Try it</button>
 //after an HTML document is loaded, it will delete all existing HTML:
• <p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 5 + 6;
</script>
• console.log(5 + 6); //Activate the browser console with F12, and select "Console" in the menu.
6
Syntax
 JavaScript statements are composed of:
Values, Operators, Expressions, Keywords, and Comments.
 Costanti: 10, 10.50,“Joe”,‘Jack’
 Variabili: var x; x=0; var y=100; var z = x + y; //VAR eVar ≠ var
 Operatori: +, -, *, /, (5 + 6) * 10
 Expressionis a combination of values, variables, and operators, which computes to a value.
 Keyword :var è un esempio di keyword
 Commenti: //, /* …*/
 In programming languages, camel case often starts with a lowercase
letter: firstName, lastName, masterCard, interCity
7
Variables & operators
 JavaScript variables are containers for storing data values
 JavaScript identifiers are case-sensitive
 the equal sign (=) is an "assignment" operator, not an "equal to"
operator (== in JavaScript)
 It's a good programming practice to declare all variables at the
beginning of a script
 var person = "John Doe", carName = "Volvo", price = 200;
 var carName = "Volvo";
var carName;
 var x = "5" + 2 + 3;
 var b=true, b2=false;
 +, -, *, /, %, ++, --, =, +=, -=, *=, /=, %=, ==, ===, !=,
!==, >, <, >=, <=
8
Functions
 A JavaScript function is a block of code designed to perform a particular task
(DEFINITION)
 A JavaScript function is executed when "something" invokes it (calls it).
(INVOCATION)
 function myFunction(a, b) {
return a * b; // Function returns the product of a and b
}
var x = myFunction(4, 3); // Function is called, return value will end up in x
Esempio Moltiplicazione
Esempio Celsius
 In JavaScript, you can use functions the same way as you use variables.
var x = toCelsius(32);
var text = "The temperature is " + x + " Centigrade";
Equivale a
var text = "The temperature is " + toCelsius(32) + " Centigrade";
9
HTML DOM
 With the HTML DOM, JavaScript can access and change all
the elements of an HTML document
10
Changing HTML Elements
 document.getElementById(“ide“) Find an element by element id
 element.innerHTML= Change the inner HTML of an element
 element.attribute= Change the attribute of an element
 element.setAttribute(attribute,value) Change the attribute of an element
 element.style.property= Change the style of an element
11
Esempi
 Esempi
document.getElementById(id).onclick=function(){code}
Adding event handler code to an onclick event
 document.getElementById("myImage").src = "landscape.jpg";
 document.getElementById("p2").style.color = "blue";
 <button type="button"
onclick="document.getElementById('id1').style.color = 'red'">
Click Me!</button>
 <input type="button" value="Hide text"
onclick="document.getElementById('p1').style.visibility='hidden'">
//hidden/visible
 <h1 onclick="this.innerHTML='Ooops!'">Click on this text!</h1>
//oppure così con la funzione oppure questo
 The onload, onunload, onchange, onmouseover, onmouseout, onfocus, onblur
12
Altro codice di esempio
13
 window.open("http://www.w3schools.com");
 myWindow = window.open("", "", "width=400, height=200");
 myWindow.close();
 myWindow.focus();
 myWindow.blur();
 myWindow.print();
 myWindow.resizeTo(500, 500);
 window.history.back();
 window.history.go(-2);
 http://www.w3schools.com/js/js_examples.asp

More Related Content

What's hot (20)

Desenvolvendo APIs usando Rails - Guru SC 2012
Desenvolvendo APIs usando Rails - Guru SC 2012Desenvolvendo APIs usando Rails - Guru SC 2012
Desenvolvendo APIs usando Rails - Guru SC 2012
 
jQuery basics
jQuery basicsjQuery basics
jQuery basics
 
&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" />
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
 
FYBSC IT Web Programming Unit III Document Object
FYBSC IT Web Programming Unit III  Document ObjectFYBSC IT Web Programming Unit III  Document Object
FYBSC IT Web Programming Unit III Document Object
 
Jquery presentation
Jquery presentationJquery presentation
Jquery presentation
 
Class 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingClass 6 - PHP Web Programming
Class 6 - PHP Web Programming
 
Broadleaf Presents Thymeleaf
Broadleaf Presents ThymeleafBroadleaf Presents Thymeleaf
Broadleaf Presents Thymeleaf
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Apache Velocity 1.6
Apache Velocity 1.6Apache Velocity 1.6
Apache Velocity 1.6
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
Java Script
Java ScriptJava Script
Java Script
 
J Query Public
J Query PublicJ Query Public
J Query Public
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
Javascript essentials
Javascript essentialsJavascript essentials
Javascript essentials
 
Web 8 | Introduction to PHP
Web 8 | Introduction to PHPWeb 8 | Introduction to PHP
Web 8 | Introduction to PHP
 
jQuery
jQueryjQuery
jQuery
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 

Viewers also liked

Introduzione al livello di rete e Dijkstra algorithm
Introduzione al livello di rete e Dijkstra algorithmIntroduzione al livello di rete e Dijkstra algorithm
Introduzione al livello di rete e Dijkstra algorithmorestJump
 
Introduzione ai Sistemi Operativi
Introduzione ai Sistemi OperativiIntroduzione ai Sistemi Operativi
Introduzione ai Sistemi OperativiorestJump
 
Python - Primi passi
Python - Primi passi Python - Primi passi
Python - Primi passi orestJump
 
Tecnologie informatiche
Tecnologie informaticheTecnologie informatiche
Tecnologie informaticheorestJump
 
Html e CSS ipertesti e siti web 4.5
Html e CSS   ipertesti e siti web 4.5Html e CSS   ipertesti e siti web 4.5
Html e CSS ipertesti e siti web 4.5orestJump
 
Asta AdWords: come funziona?
Asta AdWords: come funziona?Asta AdWords: come funziona?
Asta AdWords: come funziona?Enrico Mainero
 
Guida SEO: ecco un ebook definitivo!
Guida SEO: ecco un ebook definitivo!Guida SEO: ecco un ebook definitivo!
Guida SEO: ecco un ebook definitivo!Enrico Mainero
 
Ottimizzazione annunci adwords e adsense
Ottimizzazione annunci adwords e adsenseOttimizzazione annunci adwords e adsense
Ottimizzazione annunci adwords e adsenseEnrico Mainero
 
Creazione siti web a roma
Creazione siti web a romaCreazione siti web a roma
Creazione siti web a romaEnrico Mainero
 
jQuery - 1 | WebMaster & WebDesigner
jQuery - 1 | WebMaster & WebDesignerjQuery - 1 | WebMaster & WebDesigner
jQuery - 1 | WebMaster & WebDesignerMatteo Magni
 
Offerte e budget adwords
Offerte e budget adwordsOfferte e budget adwords
Offerte e budget adwordsEnrico Mainero
 
Le professioni del web: conosci queste opportunità?
Le professioni del web: conosci queste opportunità? Le professioni del web: conosci queste opportunità?
Le professioni del web: conosci queste opportunità? Enrico Mainero
 
HTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesignerHTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesignerMatteo Magni
 
HTML5 e Css3 - 6 | WebMaster & WebDesigner
HTML5 e Css3 - 6 | WebMaster & WebDesignerHTML5 e Css3 - 6 | WebMaster & WebDesigner
HTML5 e Css3 - 6 | WebMaster & WebDesignerMatteo Magni
 
HTML5 e Css3 - 2 | WebMaster & WebDesigner
HTML5 e Css3 - 2 | WebMaster & WebDesignerHTML5 e Css3 - 2 | WebMaster & WebDesigner
HTML5 e Css3 - 2 | WebMaster & WebDesignerMatteo Magni
 
HTML5 e Css3 - 7 | WebMaster & WebDesigner
HTML5 e Css3 - 7 | WebMaster & WebDesignerHTML5 e Css3 - 7 | WebMaster & WebDesigner
HTML5 e Css3 - 7 | WebMaster & WebDesignerMatteo Magni
 
Html 5: una breve guida!
Html 5: una breve guida!Html 5: una breve guida!
Html 5: una breve guida!Enrico Mainero
 
HTML5 e Css3 - 1 | WebMaster & WebDesigner
HTML5 e Css3 - 1 | WebMaster & WebDesigner HTML5 e Css3 - 1 | WebMaster & WebDesigner
HTML5 e Css3 - 1 | WebMaster & WebDesigner Matteo Magni
 

Viewers also liked (20)

Introduzione al livello di rete e Dijkstra algorithm
Introduzione al livello di rete e Dijkstra algorithmIntroduzione al livello di rete e Dijkstra algorithm
Introduzione al livello di rete e Dijkstra algorithm
 
Introduzione ai Sistemi Operativi
Introduzione ai Sistemi OperativiIntroduzione ai Sistemi Operativi
Introduzione ai Sistemi Operativi
 
Python - Primi passi
Python - Primi passi Python - Primi passi
Python - Primi passi
 
Tecnologie informatiche
Tecnologie informaticheTecnologie informatiche
Tecnologie informatiche
 
Html e CSS ipertesti e siti web 4.5
Html e CSS   ipertesti e siti web 4.5Html e CSS   ipertesti e siti web 4.5
Html e CSS ipertesti e siti web 4.5
 
Festa 18 anni Roma
Festa 18 anni RomaFesta 18 anni Roma
Festa 18 anni Roma
 
Asta AdWords: come funziona?
Asta AdWords: come funziona?Asta AdWords: come funziona?
Asta AdWords: come funziona?
 
Guida SEO: ecco un ebook definitivo!
Guida SEO: ecco un ebook definitivo!Guida SEO: ecco un ebook definitivo!
Guida SEO: ecco un ebook definitivo!
 
Ottimizzazione annunci adwords e adsense
Ottimizzazione annunci adwords e adsenseOttimizzazione annunci adwords e adsense
Ottimizzazione annunci adwords e adsense
 
Creazione siti web a roma
Creazione siti web a romaCreazione siti web a roma
Creazione siti web a roma
 
jQuery - 1 | WebMaster & WebDesigner
jQuery - 1 | WebMaster & WebDesignerjQuery - 1 | WebMaster & WebDesigner
jQuery - 1 | WebMaster & WebDesigner
 
Offerte e budget adwords
Offerte e budget adwordsOfferte e budget adwords
Offerte e budget adwords
 
Le professioni del web: conosci queste opportunità?
Le professioni del web: conosci queste opportunità? Le professioni del web: conosci queste opportunità?
Le professioni del web: conosci queste opportunità?
 
HTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesignerHTML5 e Css3 - 3 | WebMaster & WebDesigner
HTML5 e Css3 - 3 | WebMaster & WebDesigner
 
HTML5 e Css3 - 6 | WebMaster & WebDesigner
HTML5 e Css3 - 6 | WebMaster & WebDesignerHTML5 e Css3 - 6 | WebMaster & WebDesigner
HTML5 e Css3 - 6 | WebMaster & WebDesigner
 
HTML5 e Css3 - 2 | WebMaster & WebDesigner
HTML5 e Css3 - 2 | WebMaster & WebDesignerHTML5 e Css3 - 2 | WebMaster & WebDesigner
HTML5 e Css3 - 2 | WebMaster & WebDesigner
 
HTML5 e Css3 - 7 | WebMaster & WebDesigner
HTML5 e Css3 - 7 | WebMaster & WebDesignerHTML5 e Css3 - 7 | WebMaster & WebDesigner
HTML5 e Css3 - 7 | WebMaster & WebDesigner
 
Html 5: una breve guida!
Html 5: una breve guida!Html 5: una breve guida!
Html 5: una breve guida!
 
HTML5 e Css3 - 1 | WebMaster & WebDesigner
HTML5 e Css3 - 1 | WebMaster & WebDesigner HTML5 e Css3 - 1 | WebMaster & WebDesigner
HTML5 e Css3 - 1 | WebMaster & WebDesigner
 
Php mysql3
Php mysql3Php mysql3
Php mysql3
 

Similar to Javascript

Similar to Javascript (20)

Java script
Java scriptJava script
Java script
 
FYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III JavascriptFYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III Javascript
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Java script
Java scriptJava script
Java script
 
Java script
 Java script Java script
Java script
 
Introduction to JavaScript Basics.
Introduction to JavaScript Basics.Introduction to JavaScript Basics.
Introduction to JavaScript Basics.
 
Wt unit 5
Wt unit 5Wt unit 5
Wt unit 5
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
 
Javascript
JavascriptJavascript
Javascript
 
Web programming
Web programmingWeb programming
Web programming
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
 
Java script
Java scriptJava script
Java script
 
JavaScript with Syntax & Implementation
JavaScript with Syntax & ImplementationJavaScript with Syntax & Implementation
JavaScript with Syntax & Implementation
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Java script basics
Java script basicsJava script basics
Java script basics
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
Javascript
JavascriptJavascript
Javascript
 

Recently uploaded

VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneVIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneCall girls in Ahmedabad High profile
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 

Recently uploaded (20)

VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service PuneVIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
VIP Call Girls Pune Madhuri 8617697112 Independent Escort Service Pune
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 

Javascript

  • 2. JavaScript is one of the 3 languages all web developers must learn: 1. HTML to define the content of web pages 2. CSS to specify the layout of web pages 3. JavaScript to program the behavior of web pages 2
  • 3. <script> nella HEAD JavaScript can be placed in the <body> and the <head> sections of an HTML page. <head> <script> function myFunction() { document.getElementById("demo").innerHTML = "Paragraph changed."; } </script> </head> <body> <h1>My Web Page</h1> <p id="demo">A Paragraph</p> <button type="button" onclick="myFunction()">Try it</button> </body> 3
  • 4. <script> Nel BODY  <body> <h1>MyWeb Page</h1> <p id="demo">A Paragraph</p> <button type="button" onclick="myFunction()">Try it</button> <script> function myFunction() { document.getElementById("demo").innerHTML = "Paragraph changed."; } </script> </body> 4
  • 5. External JavaScript  Placing JavaScripts in external files has some advantages:  It separates HTML and code  It makes HTML and JavaScript easier to read and maintain  Cached JavaScript files can speed up page loads  <!DOCTYPE html> <html> <body> <script src="myScript.js"></script> </body> </html> 5
  • 6. Output  JavaScript can "display" data in different ways: • Writing into an alert box, using window.alert(). • Writing into the HTML output using document.write(). • Writing into an HTML element, using innerHTML. • Writing into the browser console, using console.log() • Esempi: • alert(5 + 6); • <button onclick="document.write(5 + 6)">Try it</button>  //after an HTML document is loaded, it will delete all existing HTML: • <p id="demo"></p> <script> document.getElementById("demo").innerHTML = 5 + 6; </script> • console.log(5 + 6); //Activate the browser console with F12, and select "Console" in the menu. 6
  • 7. Syntax  JavaScript statements are composed of: Values, Operators, Expressions, Keywords, and Comments.  Costanti: 10, 10.50,“Joe”,‘Jack’  Variabili: var x; x=0; var y=100; var z = x + y; //VAR eVar ≠ var  Operatori: +, -, *, /, (5 + 6) * 10  Expressionis a combination of values, variables, and operators, which computes to a value.  Keyword :var è un esempio di keyword  Commenti: //, /* …*/  In programming languages, camel case often starts with a lowercase letter: firstName, lastName, masterCard, interCity 7
  • 8. Variables & operators  JavaScript variables are containers for storing data values  JavaScript identifiers are case-sensitive  the equal sign (=) is an "assignment" operator, not an "equal to" operator (== in JavaScript)  It's a good programming practice to declare all variables at the beginning of a script  var person = "John Doe", carName = "Volvo", price = 200;  var carName = "Volvo"; var carName;  var x = "5" + 2 + 3;  var b=true, b2=false;  +, -, *, /, %, ++, --, =, +=, -=, *=, /=, %=, ==, ===, !=, !==, >, <, >=, <= 8
  • 9. Functions  A JavaScript function is a block of code designed to perform a particular task (DEFINITION)  A JavaScript function is executed when "something" invokes it (calls it). (INVOCATION)  function myFunction(a, b) { return a * b; // Function returns the product of a and b } var x = myFunction(4, 3); // Function is called, return value will end up in x Esempio Moltiplicazione Esempio Celsius  In JavaScript, you can use functions the same way as you use variables. var x = toCelsius(32); var text = "The temperature is " + x + " Centigrade"; Equivale a var text = "The temperature is " + toCelsius(32) + " Centigrade"; 9
  • 10. HTML DOM  With the HTML DOM, JavaScript can access and change all the elements of an HTML document 10
  • 11. Changing HTML Elements  document.getElementById(“ide“) Find an element by element id  element.innerHTML= Change the inner HTML of an element  element.attribute= Change the attribute of an element  element.setAttribute(attribute,value) Change the attribute of an element  element.style.property= Change the style of an element 11
  • 12. Esempi  Esempi document.getElementById(id).onclick=function(){code} Adding event handler code to an onclick event  document.getElementById("myImage").src = "landscape.jpg";  document.getElementById("p2").style.color = "blue";  <button type="button" onclick="document.getElementById('id1').style.color = 'red'"> Click Me!</button>  <input type="button" value="Hide text" onclick="document.getElementById('p1').style.visibility='hidden'"> //hidden/visible  <h1 onclick="this.innerHTML='Ooops!'">Click on this text!</h1> //oppure così con la funzione oppure questo  The onload, onunload, onchange, onmouseover, onmouseout, onfocus, onblur 12
  • 13. Altro codice di esempio 13  window.open("http://www.w3schools.com");  myWindow = window.open("", "", "width=400, height=200");  myWindow.close();  myWindow.focus();  myWindow.blur();  myWindow.print();  myWindow.resizeTo(500, 500);  window.history.back();  window.history.go(-2);  http://www.w3schools.com/js/js_examples.asp