XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding E-Mail Addresses from Spammers.

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
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.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Introduction to scripting
Javascript and the Web Whys and Hows of 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.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
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,
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
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.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
JavaScript Syntax, how to use it in a HTML document
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 Making Web pages come alive. Objectives Be able to read JavaScript scripts Be able to write JavaScript scripts.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
XP Tutorial 8 Adding Interactivity with ActionScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
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.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
 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,
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
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.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Chapter 6 JavaScript: Introduction to Scripting
Tutorial 10 Programming with JavaScript
Introduction to Scripting
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Objectives Insert a script element Write JavaScript comments
WEB PROGRAMMING JavaScript.
PHP.
Tutorial 10 Programming with JavaScript
Tutorial 10: Programming with javascript
An Introduction to JavaScript
JavaScript: Introduction to Scripting
CIS 136 Building Mobile Apps
Presentation transcript:

XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers

XP Tutorial 1New Perspectives on JavaScript, Comprehensive2 Objectives Understand the history and theory of JavaScript Create a script element Understand and use basic JavaScript syntax Write text to a Web document using a JavaScript command

XP Tutorial 1New Perspectives on JavaScript, Comprehensive3 Objectives Understand the different data types supported by JavaScript Declare a variable and assign it a value Reference a variable in a JavaScript statement Create and call a JavaScript function

XP Tutorial 1New Perspectives on JavaScript, Comprehensive4 Objectives Access functions from an external JavaScript file Document code with multiline and single-line comments Understand basic techniques for debugging JavaScript code

XP Tutorial 1New Perspectives on JavaScript, Comprehensive5 Staff Directory at Monroe Public Library Web Page

XP Tutorial 1New Perspectives on JavaScript, Comprehensive6 Introduction to JavaScript Spam –Junk Spammer –Person who sends spam harvester –Program that scans documents looking for addresses

XP Tutorial 1New Perspectives on JavaScript, Comprehensive7 Addresses in Staff Directory

XP Tutorial 1New Perspectives on JavaScript, Comprehensive8 Server-Side and Client-Side Programming Server-side programming –Program placed on server that hosts Web site –Program then used to modify contents and structure of Web pages

XP Tutorial 1New Perspectives on JavaScript, Comprehensive9 Server-Side and Client-Side Programming Client-side programming –Runs programs on user’s computer –Programs likely to be more responsive to users –Can never completely replace server-side programming

XP Tutorial 1New Perspectives on JavaScript, Comprehensive10 Server-Side Programming

XP Tutorial 1New Perspectives on JavaScript, Comprehensive11 Client-Side Programming

XP Tutorial 1New Perspectives on JavaScript, Comprehensive12 Combining Client-Side and Server- Side Programming

XP Tutorial 1New Perspectives on JavaScript, Comprehensive13 The Development of JavaScript Java –Developed by Sun Microsystems –Programs designed to be run within Java interpreters –An example of a compiled language JavaScript –Subset of Java –An interpreted language –Internet Explorer supports a version called JScript

XP Tutorial 1New Perspectives on JavaScript, Comprehensive14 Comparing Java and JavaScript

XP Tutorial 1New Perspectives on JavaScript, Comprehensive15 Versions of Java and JavaScript

XP Tutorial 1New Perspectives on JavaScript, Comprehensive16 Working with the Script Element Script element –Used to enter scripts into an HTML or XHTML file –Syntax script commands

XP Tutorial 1New Perspectives on JavaScript, Comprehensive17 Writing Output to a Web Document Inserting in a Web

XP Tutorial 1New Perspectives on JavaScript, Comprehensive18 The document.write() Method One way to send output to the Web document Object –Can be any item, including mouse pointer or window scrollbars Method –Process by which JavaScript manipulates the features of an object

XP Tutorial 1New Perspectives on JavaScript, Comprehensive19 Understanding JavaScript Rules and the Use of White Space JavaScript –Is case sensitive –Ignores most occurrences of extra white space –Line breaks occurring within a statement can cause error –Good practice to not break a statement into several lines

XP Tutorial 1New Perspectives on JavaScript, Comprehensive20 Supporting Non-JavaScript Browsers noscript element –Used by browsers that do not support scripts –Syntax alternative content

XP Tutorial 1New Perspectives on JavaScript, Comprehensive21 Supporting Non-JavaScript Browsers CDATA section –Marks text as data that should not be processed by XHTML parsers –Syntax <![cdata[ JavaScript code ]]>

XP Tutorial 1New Perspectives on JavaScript, Comprehensive22 Working with Variables Variable –A named item in a program that stores information –Used to represent values and text strings –Values can change as the program runs

XP Tutorial 1New Perspectives on JavaScript, Comprehensive23 Declaring a Variable Tells JavaScript interpreter to reserve memory space for the variable Statement to declare a variable var variable; Declaring three variables var emLink, userName, emServer;

XP Tutorial 1New Perspectives on JavaScript, Comprehensive24 Declaring a Variable Limits on variable names –First character must be either a letter or an underscore character ( _ ) –Remaining characters can be letters, numbers, or underscore characters –Variable names cannot contain spaces –Reserved words cannot be used

XP Tutorial 1New Perspectives on JavaScript, Comprehensive25 Assigning a Value to a Variable variable = value; Combining variable declaration and assignment in a single statement var userName = "cadler", emServer = "mpl.gov";

XP Tutorial 1New Perspectives on JavaScript, Comprehensive26 Working with Data Types Data type –Type of information stored in a variable Numeric value –Any number, such as 13, 22.5, or Text string –Any group of text characters, such as “Hello” Boolean value –Indicates the truth or falsity of a statement

XP Tutorial 1New Perspectives on JavaScript, Comprehensive27 Working with Data Types Null value – Value has not yet been assigned to variable Weakly typed language –Variables are not strictly tied to specific data types Strongly typed languages –Force programmer to explicitly identify a variable’s data type

XP Tutorial 1New Perspectives on JavaScript, Comprehensive28 Writing a Variable Value to a Web Document Variable –Can be used in place of value it contains Writing a text string to a Web page var libName = "Monroe Public Library"; document.write(libName); Plus symbol ( + ) –Can be used to combine variable with text string

XP Tutorial 1New Perspectives on JavaScript, Comprehensive29 Creating a Function to Perform an Action Functions –Collection of commands that perform an action or return a value –Include a function name –Include a set of commands that run when function is called –Some require parameters

XP Tutorial 1New Perspectives on JavaScript, Comprehensive30 Creating a Function to Perform an Action Syntax of a JavaScript function function function_name(parameters){ JavaScript commands } Calling a function function_name(parameter values)

XP Tutorial 1New Perspectives on JavaScript, Comprehensive31 Functions and Variable Scope Variable scope –Indicates where and how the variable can be used in your application –Can be local or global

XP Tutorial 1New Perspectives on JavaScript, Comprehensive32 Functions and Variable Scope Local scope –Variable created within a JavaScript function Global scope –Variables not declared within functions

XP Tutorial 1New Perspectives on JavaScript, Comprehensive33 Creating a Function to Return a Value For a function to return a value –It must include a return statement Syntax of a function that returns a value function function_name(parameters) { JavaScript commands return value; }

XP Tutorial 1New Perspectives on JavaScript, Comprehensive34 Accessing an External JavaScript File Common practice to –Create libraries of functions located in external files Script elements that point to external files are –Placed in a document’s head section Extension “.js” –Used by external files containing JavaScript commands and functions

XP Tutorial 1New Perspectives on JavaScript, Comprehensive35 Using an External Script

XP Tutorial 1New Perspectives on JavaScript, Comprehensive36 Commenting JavaScript Code Comments –Explain what your programs are designed to do and how they work Multiline comment /* The showEM() function displays a link to the user’s address. The username and server name are entered in reverse order */

XP Tutorial 1New Perspectives on JavaScript, Comprehensive37 Using Comments to Hide JavaScript Code Syntax for hiding script <!-- Hide from non-JavaScript browsers JavaScript commands // Stop hiding from older browsers -->

XP Tutorial 1New Perspectives on JavaScript, Comprehensive38 Debugging Your JavaScript Programs Load-time error –Occurs when script is first loaded by JavaScript interpreter Run-time error –Occurs after script has been successfully loaded and is being executed Logical errors –Free from syntax and structural mistakes, but result in incorrect results

XP Tutorial 1New Perspectives on JavaScript, Comprehensive39 Displaying a Logical Error

XP Tutorial 1New Perspectives on JavaScript, Comprehensive40 Common Mistakes Debugging –Process of searching code to locate a source of trouble Common errors –Misspelling a variable name –Mismatched parentheses or braces –Mismatched quotes –Missing quotes

XP Tutorial 1New Perspectives on JavaScript, Comprehensive41 Debugging Tools and Techniques Writing modular code –Breaking up a program’s different tasks into smaller, more manageable chunks Alert dialog box –Dialog box generated by JavaScript that displays a text message with an OK button Microsoft Script Debugger –Can help to create and debug JavaScript programs

XP Tutorial 1New Perspectives on JavaScript, Comprehensive42 Microsoft Debugger Window

XP Tutorial 1New Perspectives on JavaScript, Comprehensive43 Tips for Writing Good JavaScript Code Apply layout techniques to make code more readable Use descriptive variable names Be consistent in how you apply uppercase and lowercase letters to your variable names Add comments to your code

XP Tutorial 1New Perspectives on JavaScript, Comprehensive44 Tips for Writing Good JavaScript Code Create customized functions Break up long and complicated functions into smaller functions Use the debugging tools available In case of a logical error, use alert boxes