1 JavaScript E-Commerce Prof. Sheizaf Rafaeli

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Essentials for Design JavaScript Level One Michael Brooks
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
1 COMM 1213 H1 COMP 4923 X1 JavaScript 1 (Readings: Ch. 10, 11 Knuckles)
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
The Web Warrior Guide to Web Design Technologies
Introduction to JavaScript Programming. World Wide Web Original purpose was locating and displaying information Small academic and scientific community.
JavaScript 101 Lesson 01: Writing Your First JavaScript.
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.
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Web Development & Design Foundations with XHTML Chapter 14 Key Concepts.
CIS101 Introduction to Computing Week 09 Spring 2004.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Introduction to scripting
Javascript and the Web Whys and Hows of Javascript.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Generations of Programming Languages First generation  Machine Language Second Generation  Assembly Language Third Generation  Procedural language such.
Database-Driven Web Sites, Second Edition1 Chapter 3 INTRODUCTION TO CLIENT-SIDE SCRIPTS.
Internet Mark-up Languages CO32036 Part Lecture: Elementary JavaScript.
Lesson 19. JavaScript errors Since JavaScript is an interpreted language, syntax errors will usually cause the script to fail. Both browsers will provide.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
Flash & JavaScript Mariela Hristova October 19, 2004 INF 385E – Fall 2004 – School of Information.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
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. 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.
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
JS Basics 1 Lecture JavaScript - Basics. JS Basics 2 What is JavaScript JavaScript is a “simple”, interpreted, programming language with elementary object-
Intro to JavaScript. Some simple examples Examples from our webpage Examples from Andrews webpage Today’s Example.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
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.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
 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.
1 Server versus Client-Side Programming Server-SideClient-Side.
1 JavaScript in Context. Server-Side Programming.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Lesson 30: JavaScript and DHTML Fundamentals. Objectives Define and contrast client-side and server-side technologies used to create dynamic content for.
JavaScript and Ajax (JavaScript Basic) Week 2 Web site:
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 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.
© 2010 Robert K. Moniot1 Chapter 6 Introduction to JavaScript.
Web Development & Design Foundations with HTML5
Tutorial 10 Programming with JavaScript
Web Programming– UFCFB Lecture 13
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

1 JavaScript E-Commerce Prof. Sheizaf Rafaeli

2 E-Business, Sheizaf Rafaeli JavaScript intro n Javascript is a programming language n It is a simple, object-based interpreted scripting language n Code is usually embedded in the HTML n Javascript is NOT Java n Javascript is not Jscript or Active-X, but Jscript tries to be compatible n Created by Netscape

3 E-Business, Sheizaf Rafaeli Strengths and weaknesses n Easy to learn n Quick development n Easy to debug n Platform independent n Small overhead n Limited range of built- in methods n No code hiding n Debugging and development tools are still lacking n Unstable, compatibility?

4 E-Business, Sheizaf Rafaeli Javascript JavaScript usually goes between the tag and the tag, but can go elsewhere too. n n JavaScript begins with – – JavaScripts end with the tag. Use and Comments use the // and /* -- */ pair. n Worry about hiding scripts

5 E-Business, Sheizaf Rafaeli Very Simple Example document.write(“shalom!")</script>

6 E-Business, Sheizaf Rafaeli Javascript (2) n Javascript is case sensitive n Is flexible about statements and white space n Scripts are evaluated as soon as the code is encountered n Functions can be defined anywhere. n However they only get executed when called

7 E-Business, Sheizaf Rafaeli Javascript hiding scripts from incompatible browsers Whatever <!-- hide stuff from other browsers YOUR SCRIPT HERE // end the hiding comment -->

8 E-Business, Sheizaf Rafaeli Main concepts

9 E-Business, Sheizaf Rafaeli Topical Outline n Variables n alert, prompt, document.writeln n Strings as objects n If-then branching n Link events (onClick, OnMouseover) n Opening new windows (“targeting”) n Object oriented programming, and esp. the Document Object Model n Loops, arrays and functions n Forms, OnChange, OnLoad

10 E-Business, Sheizaf Rafaeli Brief overview of object-oriented programming n n Built-in library of objects – –Window, Math, String, Document, Form, Navigator, etc. n Objects have properties and methods n See Javascript cheatsheet for summaries and tables, at: – –

11 E-Business, Sheizaf Rafaeli Object Oriented programming (2) An object's property is set like this: » »window.status = ”Look at this!"; An object is called the same way that a property is accessed: the object name, a period, and then the method. n n Later versions have more objects, properties, and methods.

12 E-Business, Sheizaf Rafaeli Javascript variables n Variables can be declared using var (but not required). n n Variable names must start with either a letter or the underscore character. n n Variable names are case-sensitive in most, but not all, versions n n Statements end with a semicolon. n n Spaces and line breaks are ignored by the JavaScript interpreter

13 E-Business, Sheizaf Rafaeli Javascript examples n Stroke the squares – n Favorite Animal (forms) – n Simple calculations – n Intranets (Montana) – n Validate a form – – n “Has E” validation –

14 E-Business, Sheizaf Rafaeli Javascript examples (2) n See collections, at: – ript.examples.html »Calculator, Calendar, Rotating menu, Multiplication table, Using cookies, Decision support, Encryption – –

15 E-Business, Sheizaf Rafaeli Simple examples (1) n Click event: n Click event:

16 E-Business, Sheizaf Rafaeli Simple examples (2) <!-- hide from old browsers <!-- hide from old browsers document.write(“Hail to the Victors Valiant "); document.write(“Hail to the Conquering Heroes "); document.write(“Hail to the Victors Valiant "); document.write(“Hail to the Conquering Heroes "); document.write(“Hail to the Victors Valiant "); document.write(“Hail to the Conquering Heroes "); // --> // -->

17 E-Business, Sheizaf Rafaeli Simple examples (3) <!-- hide function myFunction() {document.write(“Hail to the Victors Valiant "); document.write(“Hail to the Conquering Heroes "); }myFunction();myFunction();myFunction(); // --> // -->

18 E-Business, Sheizaf Rafaeli Simple examples (4) <!-- hide function calculation() { var x= 12; var y= 5; var result= x + y; var x= 12; var y= 5; var result= x + y; alert(result);} // -- > alert(result);} // -- > </head><body><form> </form></body></html>

19 E-Business, Sheizaf Rafaeli Simple examples (5) <!-- hide function openWin() { myWin= open("l6.htm");} // --> </head><body><form>

20 E-Business, Sheizaf Rafaeli Simple examples (6) <!-- Hide function test1(form) { if (form.text1.value == "") alert('Please enter a string!'); else { alert("Hi "+form.text1.value+"! Form input ok!"); }} function test2(form) { if (form.text2.value == "" || 0) == -1) alert("No valid address!"); alert("No valid address!"); else alert("OK!");} else alert("OK!");} // -- > example 12: Enter your name: Enter your address:

21 E-Business, Sheizaf Rafaeli Error messages? Why do I get JavaScript errors when using IE 3.0? When viewing a JavaScript-enabled Web site with Microsoft Internet Explorer 3.0, it's not uncommon to receive an error message in an Internet Explorer Script Error window. Microsoft released Internet Explorer 3.0 before Netscape published its proprietary JavaScript 1.1 specification. For this reason, Microsoft refers to Internet Explorer's JavaScript implementation as "Jscript", which isn't completely compatible with Netscape's JavaScript. Internet Explorer 4.0, the latest release of the browser, is compatible with the specification. If you use Internet Explorer 4.0 to view the Web site in question, you shouldn't receive an error message.

22 E-Business, Sheizaf Rafaeli Debugging n n Beginning JavaScript authors can easily debug single lines of code in Navigator. In the Location box, enter either MOCHA: or JAVASCRIPT: (including the colon) and the debugging window opens.

23 E-Business, Sheizaf Rafaeli Online resources n Netscape’s JavaScript guide – ation/communicator/jsguide4/index.htm n Netscape’s Sample form validation scripts, at: – – es/javascript/formval/overview.html

24 E-Business, Sheizaf Rafaeli Online resources (2) n Javascript 411: – – n Javascript “Tip of the Week” – n The Javascript resource center –

25 E-Business, Sheizaf Rafaeli Online resources (3) n Danny Goodman’s pages – – n n Gordon McComb’s pages – – n n Usenet’s comp.lang.javascript