SlideShare a Scribd company logo
1 of 15
JavaScript and CSS in
HTML5 Web Development
   HTML5 Multimedia Developer’s Guide
             Chapter Two
Where does HTML fit in?

 HTML is basic web page language
   Does nothing much more than lay out
   items on the page
   No power to crunch numbers, process
   data, etc.
   Just structures the page
What does JavaScript do?
   JavaScript adds the punch
     Can move an item on the page
     Can perform sophisticated
     calculations
     Through conditional statements, can
     make decisions and branch out to
     specific code
How about CSS?
Like HTML, CSS does not bring
processing power
Instead, it makes the page look however
you might imagine it should
CSS3 is latest standard
  However, cross-browser support is still
  developing, so you have to test in
  different browsers
How does JavaScript run?

When page is served, activity is “First come,
first served”
   Browser renders top-to-bottom, left-to-
   right
When JS is in-line, it is run as the browser
encounters it. (This could be good or bad)
Controlling when JS runs

Two ways to control when JavaScript code
runs:
  Place the JavaScript in a function, and
  then call that function
  Place the JavaScript in your HTML
  precisely where you want it to run
Code Listing 2-2



We’re going to type in this code, and then
test it
Results of 2-2


Why doesn’t “This is the content of div 1”
appear blue and bold?
How could we fix this?
Code Listing 2-3



We’re going to type this code, and then test
it
Results of 2-3


See the difference?
Why was it different?
Loops & Conditional Tests


Looping allows us to repeat sections of code
Conditional Tests allow us to interact with
activities in the browser, and choose specific
code to run
For Loops
A for loop repeats code as long as a specific
condition exists
for (i=0; i<=10; i++) {
    document.write(i + ‘<br>’);
    }
Switch Statements
A Switch statement tests an expression that has
specific values. Code is executed depending on
which value is returned.
var d= new Date();
switch (d.getDay().toString()) {
     case “0”:
     document.write(‘<br><br>Today is Sunday’);
     break;
Code Listing 2-4



We’ll type this code and see what it does
External JavaScript
So far, we’ve put all our JavaScript inside our web
page using <script> tags
You can also put your JavaScript in an external file,
and link to it from the web page
   This is useful if the same JavaScript file is used
   by more than 1 web page
<script src=”js/common.js”></script>

More Related Content

What's hot

Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentation
Scott Messinger
 
Java script how to
Java script how toJava script how to
Java script how to
julian vega
 

What's hot (20)

Javascripts. pptt
Javascripts. ppttJavascripts. pptt
Javascripts. pptt
 
Ui automation
Ui automationUi automation
Ui automation
 
Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentation
 
Java script
Java scriptJava script
Java script
 
Introduction to ReactJs & fundamentals
Introduction to ReactJs & fundamentalsIntroduction to ReactJs & fundamentals
Introduction to ReactJs & fundamentals
 
Java script how to
Java script how toJava script how to
Java script how to
 
Javascipt
JavasciptJavascipt
Javascipt
 
Serverless Application Development with MongoDB Stitch
Serverless Application Development with MongoDB StitchServerless Application Development with MongoDB Stitch
Serverless Application Development with MongoDB Stitch
 
Proficy machine edition logging
Proficy machine edition loggingProficy machine edition logging
Proficy machine edition logging
 
ReactJs
ReactJsReactJs
ReactJs
 
Knockoutjs
KnockoutjsKnockoutjs
Knockoutjs
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
Javascript and DOM
Javascript and DOMJavascript and DOM
Javascript and DOM
 
Lab work servlets and jsp
Lab work servlets and jspLab work servlets and jsp
Lab work servlets and jsp
 
Javascript
JavascriptJavascript
Javascript
 
React event
React eventReact event
React event
 
How To Become A Web Page Master Builder
How To Become A Web Page Master BuilderHow To Become A Web Page Master Builder
How To Become A Web Page Master Builder
 
Knockout vs Zombies
Knockout vs ZombiesKnockout vs Zombies
Knockout vs Zombies
 
Javascript dom event
Javascript dom eventJavascript dom event
Javascript dom event
 
Java script cookies
Java script   cookiesJava script   cookies
Java script cookies
 

Viewers also liked

Castro Chapter 7
Castro Chapter 7Castro Chapter 7
Castro Chapter 7
Jeff Byrnes
 
Castro Chapter 3
Castro Chapter 3Castro Chapter 3
Castro Chapter 3
Jeff Byrnes
 
Castro Chapter 6
Castro Chapter 6Castro Chapter 6
Castro Chapter 6
Jeff Byrnes
 
Castro Chapter 4
Castro Chapter 4Castro Chapter 4
Castro Chapter 4
Jeff Byrnes
 
Castro Chapter 5
Castro Chapter 5Castro Chapter 5
Castro Chapter 5
Jeff Byrnes
 
Castro Chapter 15
Castro Chapter 15Castro Chapter 15
Castro Chapter 15
Jeff Byrnes
 
Financial analysis pp
Financial analysis ppFinancial analysis pp
Financial analysis pp
JoeVelarde
 
INFO3775 Chapter 2 Part 2
INFO3775 Chapter 2 Part 2INFO3775 Chapter 2 Part 2
INFO3775 Chapter 2 Part 2
Jeff Byrnes
 

Viewers also liked (8)

Castro Chapter 7
Castro Chapter 7Castro Chapter 7
Castro Chapter 7
 
Castro Chapter 3
Castro Chapter 3Castro Chapter 3
Castro Chapter 3
 
Castro Chapter 6
Castro Chapter 6Castro Chapter 6
Castro Chapter 6
 
Castro Chapter 4
Castro Chapter 4Castro Chapter 4
Castro Chapter 4
 
Castro Chapter 5
Castro Chapter 5Castro Chapter 5
Castro Chapter 5
 
Castro Chapter 15
Castro Chapter 15Castro Chapter 15
Castro Chapter 15
 
Financial analysis pp
Financial analysis ppFinancial analysis pp
Financial analysis pp
 
INFO3775 Chapter 2 Part 2
INFO3775 Chapter 2 Part 2INFO3775 Chapter 2 Part 2
INFO3775 Chapter 2 Part 2
 

Similar to INFO 3775 Chapter 2 Part 1

Intro to Javascript and jQuery
Intro to Javascript and jQueryIntro to Javascript and jQuery
Intro to Javascript and jQuery
Shawn Calvert
 
Java Script - A New Look
Java Script - A New LookJava Script - A New Look
Java Script - A New Look
rumsan
 

Similar to INFO 3775 Chapter 2 Part 1 (20)

Web 2.0
Web 2.0Web 2.0
Web 2.0
 
Knockout js session
Knockout js sessionKnockout js session
Knockout js session
 
Unit 4(it workshop)
Unit 4(it workshop)Unit 4(it workshop)
Unit 4(it workshop)
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students
 
Intro to Javascript and jQuery
Intro to Javascript and jQueryIntro to Javascript and jQuery
Intro to Javascript and jQuery
 
13-IntroJavascript.pptx
13-IntroJavascript.pptx13-IntroJavascript.pptx
13-IntroJavascript.pptx
 
13-IntroJavascript.pptx
13-IntroJavascript.pptx13-IntroJavascript.pptx
13-IntroJavascript.pptx
 
13-IntroJavascript.pptx
13-IntroJavascript.pptx13-IntroJavascript.pptx
13-IntroJavascript.pptx
 
Javascript session 1
Javascript session 1Javascript session 1
Javascript session 1
 
JavaScript: DOM and jQuery
JavaScript: DOM and jQueryJavaScript: DOM and jQuery
JavaScript: DOM and jQuery
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Java script basics
Java script basicsJava script basics
Java script basics
 
Java Script - A New Look
Java Script - A New LookJava Script - A New Look
Java Script - A New Look
 
PPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to serverPPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to server
 
Think jQuery
Think jQueryThink jQuery
Think jQuery
 
Java script
Java scriptJava script
Java script
 
Html javascript
Html javascriptHtml javascript
Html javascript
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery Presentation
 
Developing node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDBDeveloping node-mdb: a Node.js - based clone of SimpleDB
Developing node-mdb: a Node.js - based clone of SimpleDB
 

More from Jeff Byrnes

Castro Chapter 11
Castro Chapter 11Castro Chapter 11
Castro Chapter 11
Jeff Byrnes
 
Castro Chapter 10
Castro Chapter 10Castro Chapter 10
Castro Chapter 10
Jeff Byrnes
 
Castro Chapter 9
Castro Chapter 9Castro Chapter 9
Castro Chapter 9
Jeff Byrnes
 
Castro Chapter 8
Castro Chapter 8Castro Chapter 8
Castro Chapter 8
Jeff Byrnes
 
Castro Chapter 2
Castro Chapter 2Castro Chapter 2
Castro Chapter 2
Jeff Byrnes
 
Castro Chapter 2
Castro Chapter 2Castro Chapter 2
Castro Chapter 2
Jeff Byrnes
 

More from Jeff Byrnes (6)

Castro Chapter 11
Castro Chapter 11Castro Chapter 11
Castro Chapter 11
 
Castro Chapter 10
Castro Chapter 10Castro Chapter 10
Castro Chapter 10
 
Castro Chapter 9
Castro Chapter 9Castro Chapter 9
Castro Chapter 9
 
Castro Chapter 8
Castro Chapter 8Castro Chapter 8
Castro Chapter 8
 
Castro Chapter 2
Castro Chapter 2Castro Chapter 2
Castro Chapter 2
 
Castro Chapter 2
Castro Chapter 2Castro Chapter 2
Castro Chapter 2
 

INFO 3775 Chapter 2 Part 1

  • 1. JavaScript and CSS in HTML5 Web Development HTML5 Multimedia Developer’s Guide Chapter Two
  • 2. Where does HTML fit in? HTML is basic web page language Does nothing much more than lay out items on the page No power to crunch numbers, process data, etc. Just structures the page
  • 3. What does JavaScript do? JavaScript adds the punch Can move an item on the page Can perform sophisticated calculations Through conditional statements, can make decisions and branch out to specific code
  • 4. How about CSS? Like HTML, CSS does not bring processing power Instead, it makes the page look however you might imagine it should CSS3 is latest standard However, cross-browser support is still developing, so you have to test in different browsers
  • 5. How does JavaScript run? When page is served, activity is “First come, first served” Browser renders top-to-bottom, left-to- right When JS is in-line, it is run as the browser encounters it. (This could be good or bad)
  • 6. Controlling when JS runs Two ways to control when JavaScript code runs: Place the JavaScript in a function, and then call that function Place the JavaScript in your HTML precisely where you want it to run
  • 7. Code Listing 2-2 We’re going to type in this code, and then test it
  • 8. Results of 2-2 Why doesn’t “This is the content of div 1” appear blue and bold? How could we fix this?
  • 9. Code Listing 2-3 We’re going to type this code, and then test it
  • 10. Results of 2-3 See the difference? Why was it different?
  • 11. Loops & Conditional Tests Looping allows us to repeat sections of code Conditional Tests allow us to interact with activities in the browser, and choose specific code to run
  • 12. For Loops A for loop repeats code as long as a specific condition exists for (i=0; i<=10; i++) { document.write(i + ‘<br>’); }
  • 13. Switch Statements A Switch statement tests an expression that has specific values. Code is executed depending on which value is returned. var d= new Date(); switch (d.getDay().toString()) { case “0”: document.write(‘<br><br>Today is Sunday’); break;
  • 14. Code Listing 2-4 We’ll type this code and see what it does
  • 15. External JavaScript So far, we’ve put all our JavaScript inside our web page using <script> tags You can also put your JavaScript in an external file, and link to it from the web page This is useful if the same JavaScript file is used by more than 1 web page <script src=”js/common.js”></script>