Introduction to Programming and JavaScript

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

Essentials for Design JavaScript Level One Michael Brooks
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Java Script Session1 INTRODUCTION.
The Web Warrior Guide to Web Design Technologies
JavaScript- Introduction. What it is and what it does? What it is? It is NOT Java It is NOT Server-side programming Users can see code It is a client-side.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 7 Event-Driven.
HTML Recall that HTML is static in that it describes how a page is to be displayed, but it doesn’t provide for interaction or animation. A page created.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
Tutorial 1: Introduction to JavaScript JavaScript - Introductory.
Inline, Internal, and External FIle
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
Javascript and the Web Whys and Hows of Javascript.
4.1 JavaScript Introduction
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
JavaScript Tutorial 1 - Introduction to JavaScript WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Introduction to JavaScript – A First.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
Introduction to JavaScript CS101 Introduction to Computing.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
JavaScript Defined JavaScript Basics Definitions JavaScript is an object-oriented programming language designed for the world wide web. JavaScript code.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
Introduction to Programming and JavaScript. Programming.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Introduction to.
Module 1 Introduction to JavaScript
Applied Component I Unit II Introduction of java-script
Using DHTML to Enhance Web Pages
Unit M Programming Web Pages with
Chapter 6 JavaScript: Introduction to Scripting
Using JavaScript to Show an Alert
Web Development & Design Foundations with HTML5
JavaScript Wrap-up.
JavaScript is a programming language designed for Web pages.
Section 17.1 Section 17.2 Add an audio file using HTML
Web Development & Design Foundations with HTML5 7th Edition
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript Introduction
DHTML Javascript Internet Technology.
WEB PROGRAMMING JavaScript.
Events Comp 205 Fall 2017.
DHTML Javascript Internet Technology.
The Web Wizard’s Guide To JavaScript
Introduction to JavaScript
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
JavaScript and Ajax (JavaScript Events)
Information Retrieval and Web Design
Presentation transcript:

Introduction to Programming and JavaScript

What is a Program? Instructions Computer Understands Perform Task

What is Programming? Requirements Process Code Test

Control Structures Sequence Conditional Open File Format File Print File Save File Close File Get Section Status Section Full? Register Student Reject Registration No Yes

Control Structures Spaghetti Code! Loop Transfer (GoTo) Open Student File Get Student Record Print Grade Report Students Left? Close Student File Yes No Open File Print File Format File Close File Save File Spaghetti Code!

JavaScript <script type="text/javascript"> function shutdown() { Sctipts are a series of instructions; a mini-program that only runs within an application. Web designer includes JavaScript instructions into an HTML source document; on the browser side a JavaScript interpreter is built into most browsers. The browser translates the JavaScript along with the HTML code. The alert command causes an alert box to display on the screen with a message inside. In the above example the box would read Shutting Down Internet. Capialization matters. It must be alert and not Alert. Use the <script> tag to indicate to the browser where the JavaScript code begins. <script type="text/javascript"> function shutdown() { alert('Shutting Down Internet.') } </script>

JavaScript A programming language. Executed as a script. Object oriented. Extensive document object model (DOM). No file read/write access (except cookies). <script type="text/javascript"> function shutdown() { alert('Shutting Down Internet.') } </script>

<script> <script type=“text/javascript”> Program code written in JavaScript. JavaScript comments. NO HTML! In the script tag the type attribute specifies which type of script syntax/language is embeded in the code. In the past programmers have used the language attribute instead of the type attribute. It allows to designate which verision i.e. language=“JavaScript1.2” 1.5 is the most recent version. The other script is VBScript but it only works with IE. <script> and </script> are part of HTML…everything in between those tags are valid JavaScript statements. You will get an error message, when the page loads, if you put HTML code in the JavaScript. HTML document example like page 191.

Script Locations External Script <html> File <head> <script> … </script> Script is reusable. “Call” script to execute it. It is possible to have more than one <script> element, and they may be in the <head> or <body> elements. Use multiple <script> elements when you want the browser to execute some JavaScript, then execute some HTML, then execute some more JavaScript. The <script>element may also be used to access JavaScript code that is stored in another file, known as an external file. This external file is a text file that has been saved with a .js extension i.e. testCode.js – it can only contain JavaScript (no HTML). Use the src attribute to script element i.e. <script src=“testCode.js” type=“text/javascript”> </script> When the browser loads this from the HTML document it will retrieve and load the testCode.js file. The testCode.js must be in the same directory or the full pathname is required. </head> <body> <script> … </script> Script is executed as the browser displays the web page. </body> </html>

Bugs – Syntax Errors error is here! line 8 <html> <head> <script type="text/javascript"> function shutdown() { do alert('Shutting Down Internet.') } </script> </head> <body> <h1>Shutdown Internet?</h1> <input type="button" value="Shutdown Internet" onclick="shutdown()" /> </body> </html> error is here! line 8

Bugs – Runtime Errors <html> <head> <script type="text/javascript"> function shutdown() { alert('Shutting Down Internet.') } </script> </head> <body> <h1>Shutdown Internet?</h1> <input type="button" value="Shutdown Internet" onclick="do_onclick()" /> </body> </html>

Bugs – Logic Errors function compute_gross_pay(hours, rate) { Gross = hours + rate return Gross }

Comments Please! JavaScript code … // comment continues on this line and on this line */ JavaScript code … /* comment starts on this line and continues on this line

Objects, Events, & Event Handlers <body> <h1>Shutdown Internet?</h1> <input type="button" value="Shutdown Internet" onclick="shutdown()" /> </body> Click button = Click Event The <noscript> element will display a message to surfers whose browsers do not support JavaScript. It is placed at or near the beginning of the <body> section. It is a good practice to display a warning message. The main benefit of JavaScript is the ability to make the pages interactive. Let’s look at Click buttons and click events. A click button is one type of input element that may be added to a web page. Input elements allow the user to input information. The <input> tag inside a <form> element will add the button. The type attribute tells the browser what type of input element to display and the name attribute is internal for the programmer’s use; the value attribute tells what text label for the input type. <input is an empty element that req a /> at the end. At this point click on the button triggers nothing. The event of clicking on the button will activate an event handler (onclick attribute in the button’s <input> tag) for that object which contains the JavaScript commands. There is also the mouseover (pointer over a link text) and mouseout events (pointer off of a link text). But we will do more with these in Chapter 9. Exercise 7.3 page 209. <html> <head> <title> A click button</title> </head> <body> Here’s simple click button: <form> <input type=“button” name=“b1” value=“Click here!”/> <input type=“button” name=“b1” value=“Click here!” onclick=“alert(‘Nice going!’)” /> </form> </body> </html> Object <head> <script type="text/javascript"> function shutdown() { alert('Shutting Down Internet.') } </script> </head>

JavaScript Date in Web Page document.write(document.lastModified) IE: 11/14/2004 20:37:56 Mozilla: Sunday, November 14, 2004 20:37:34