1 / 11

Introduction to JavaScript

Introduction to JavaScript. Week 1 - Presentation 1 Veronica Noone. Objectives. What is JavaScript? Why JavaScript? What can it do? HTML Review <script> tag Our First Script Lab 01 - bgcolor changer. What is JavaScript?. Interpreted Computer Language Not compiled

Download Presentation

Introduction to JavaScript

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to JavaScript Week 1 - Presentation 1 Veronica Noone

  2. Objectives • What is JavaScript? • Why JavaScript? • What can it do? • HTML Review • <script> tag • Our First Script • Lab 01 - bgcolor changer

  3. What is JavaScript? • Interpreted Computer Language • Not compiled • Code get’s interpreted every time it is executed (run) • It’s NOT Java - originally LiveScript • Just needs a browser to run • Can run locally no need to “serve”

  4. Why JavaScript? • Supported by the most common browsers • Versatile • Can be used with within PDF files • Easy to learn • It’s FUN!

  5. What can it do? • Interact with users • Validate user data • Automate tasks • Calculators • “Tricks” • Rollovers • Scrolling text With some Inventiveness and Creativity you can do a lot!

  6. Examples • http://www.nhlbisupport.com/bmi/ • http://student.ccbcmd.edu/~vnoone • Warning!! Some of these are EXTREME! • http://domscripting.com/domsters/index.html • http://script.aculo.us/ • http://www.themaninblue.com/writing/perspective/2005/10/05/slideshow/index.htm • http://www.scottschiller.com/

  7. Ok, let’s take a look but first… • HTML Review <html> <head> <title>Sample Test Page</title> </head> <body> <h1>Basic HTML structure</h1> <p>This is just a sample HTML page with a head, a body and a few tags</p> </body> </html>

  8. <script> tag • Informs the browsers built in JavaScript interpreter to run the code • The text of the code is not shown to the user • Can go in the head or the body <script language="javascript" type="text/javascript"> <!--// //code goes here // --> </script>

  9. Our First Script <html> <head> <title>Our First Script</title> <script language="javascript" type="text/javascript"> <!--// alert("First Script Block in Head"); // --> </script> </head> <body bgcolor="white"> <h1>Our First Script - Heading 1</h1> <script language="javascript" type="text/javascript"> <!--// // Script block 1 alert("First Script Block after Head"); // --> </script> <p>Paragragh 1</p> <script language="javascript" type="text/javascript"> <!--// // Script block 2 document.bgColor = "red"; alert("Second Script Block after paragragh"); // --> </script> <p>Paragragh 2</p> <script language="javascript" type="text/javascript"> <!--// // Script block 2 document.bgColor = "blue"; alert("Third Script Block"); // --> </script> </body> </html> No Seriously, Let’s take A look • Go to the class web page • Right click on w01p01ex01.html and save the file to your desktop

  10. Things to notice… • // • document.bgcolor • Alert() function • Message is the parameter • Modal • ; • Semicolons end a statement

  11. Week 01 Lab 01 Background Color Changer • Code a document to alert the user of a background color change 3 times. • For example… • Page loads • user is alerted that the BG color will change to red. The BG changes to red • user is the then alerted the BG will change to green, the BG changes, • you get the idea. • CHALLENGE: Use only one script tag • Lab worth 10 points

More Related