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

💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋nirzagarg
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...nirzagarg
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Delhi Call girls
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftAanSulistiyo
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...tanu pandey
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查ydyuyu
 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...SUHANI PANDEY
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrHenryBriggs2
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceDelhi Call girls
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋nirzagarg
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...roncy bisnoi
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...SUHANI PANDEY
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge GraphsEleniIlkou
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...tanu pandey
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...SUHANI PANDEY
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 

Recently uploaded (20)

💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
Thalassery Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call G...
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Bilaspur Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
 

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