Tutorial 10 Programming with JavaScript

Slides:



Advertisements
Similar presentations
/ 251 Internet Applications Ahmed M. Zeki Sem – / Chapter 8.
Advertisements

Introducing JavaScript
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
The Web Warrior Guide to Web Design Technologies
2440: 211 Interactive Web Programming JavaScript Fundamentals.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Tutorial 14 Working with Forms and Regular Expressions.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Introduction to scripting
4.1 JavaScript Introduction
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
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.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
การสคริปท์ฝั่งลูกข่ายด้วย JavaScript การเขียนโปรแกรมเว็บ.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
JavaScript Syntax, how to use it in a HTML document
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Client-Side Scripts JavaScript CIS January 2005.
XP Tutorial 8 Adding Interactivity with ActionScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
XP Tutorial 10 Section 1 1 Programming with JavaScript.
Web111a_chapt08.ppt HTML: Section 8 JavaScript CGI Programs (Server Side programs) Common Gateway Interface Run on server Communicate with user across.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 Server versus Client-Side Programming Server-SideClient-Side.
1 JavaScript in Context. Server-Side Programming.
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.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Tutorial 10 Programming with JavaScript
Introduction to Scripting
JavaScript an introduction.
Objectives Insert a script element Write JavaScript comments
WEB PROGRAMMING JavaScript.
Tutorial 10 Programming with JavaScript
Tutorial 10: Programming with javascript
An Introduction to JavaScript
CIS 136 Building Mobile Apps
Presentation transcript:

Tutorial 10 Programming with JavaScript

Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write text to a Web page with JavaScript Learn about JavaScript data types New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Objectives Declare and work with variables Create and call a JavaScript function Access an external JavaScript file Add comments to JavaScript code Learn about basic debugging techniques and tools New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Introducing JavaScript Server-side programs are placed on the server that hosts a Web site Can be problematic Client-side programming runs programs on each user’s computer New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Introducing JavaScript Server-Side Programming Client-Side Programming New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

The Development of JavaScript JavaScript is a subset of Java Differences between Java and JavaScript: Java is a compiled language JavaScript is an interpreted language New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Comparing Java and JavaScript New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

The Development of JavaScript Jscript is a version of JavaScript supported by Internet Explorer The European Computer Manufacturers Association (ECMA) develops scripting standards The standard is called ECMAScript but browsers still generally call is JavaScript New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with the Script Element A JavaScript program can either be placed directly in a Web page file or saved in an external text file Insert a client-side script in a Web page when using the script element <script type="mime-type"> script commands </script> New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Inserting JavaScript into a Web Page File Each statement—also known as a command—is a single line that indicates an action for the browser to take The semicolon notifies the browser that it has reached the end of the statement New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Writing Output to the Web Page An object is any item—from the browser window itself to a document displayed in the browser to an element displayed within the document A method is a process by which JavaScript manipulates or acts upon the properties of an object New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Writing Output to the Web Page To write text to a Web page, use the following JavaScript commands: document.write(“text”); or document.writeln(“text”)’ where text is the content to be written to the page. The doucment.write() and document.writeln() methods are identical, except that the document.writeln() method preserves any line breaks in the text string New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Understanding JavaScript Syntax JavaScript is case sensitive Ignores most occurrences of extra white space Do not break a statement into several lines The + symbol used in this command combines several text strings into a single text string New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Variables A variable is a named item in a program that stores information Most JavaScript programs use variables to represent values and text strings New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Declaring a JavaScript Variable You can declare variables with any of the following JavaScript commands: var variable; var variable = value; variable = value; where variable is the name of the variable and value is the initial value of the variable. The first command creates the variable without assigning it a value; the second and third commands both create the variable and assign it a value New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Variables and Data JavaScript variable types: Numeric variables String variables Boolean variables Null variables You must declare a variable before using it New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Variables and Data Numeric variable- any number, such as 13, 22.5, etc. Can also be expressed in scientific notation String variable- any group of text characters, such as “Hello” or “Happy Holidays!” Must be enclosed within either double or single quotations (but not both) Boolean variable- accepts only true and false values Null variable- has no value at all New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Working with Variables and Data JavaScript is a weakly typed language The + symbol can be used with either numeric values or text strings var total = 5 + 4; var emLink = "cadler" + "@" + "mpl.gov"; New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Creating a JavaScript Function A function is a collection of commands that performs an action or returns a value A function name identifies a function Parameters are values used by the function The function is executed only when called by another JavaScript command function_name(parameter values) New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Creating a JavaScript Function New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Creating a Function to Return a Value For a function to return a value, it must include a return statement function function_name(parameters){ JavaScript commands return value; } New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Accessing an External JavaScript File The code to access an external script file is: <script src="url" type="mime-type"></script> Place all script elements that reference external files in the document head New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Accessing an External JavaScript File New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Commenting JavaScript Code Commenting your code is an important programming practice // comment text New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Using Comments to Hide JavaScript Code <script type="text/javascript"> <!--Hide from nonJavaScript browsers JavaScript commands // Stop hiding from older browsers --> </script> New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Debugging Your JavaScript Programs Debugging is the process of searching code to locate a source of trouble There are three types of errors: Load-time errors Run-time errors Logical errors New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Debugging Your JavaScript Programs Modular code entails breaking up a program’s different tasks into smaller, more manageable chunks An alert dialog box is a dialog box generated by JavaScript that displays a text message with an OK button alert(text); New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Debugging Your JavaScript Programs Microsoft offers the Microsoft Script Debugger Firefox also provides the Firefox Error Console New Perspectives on HTML, XHTML, and Dynamic HTML, 4e

Debugging Your JavaScript Programs New Perspectives on HTML, XHTML, and Dynamic HTML, 4e