AdvWeb-1/29 DePaul University SNL 262 Advanced Web Page Design Introduction To JavaScript - II Instructor: David A. Lash.

Slides:



Advertisements
Similar presentations
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
1 COMM 1213 H1 COMP 4923 X1 JavaScript 1 (Readings: Ch. 10, 11 Knuckles)
Java Script Session1 INTRODUCTION.
JavaScript Objects - DOM CST 200 JavaScript. Objectives Introduce JavaScript objects Introduce Document Object Model Introduce window object Introduce.
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.
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.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 8: JavaScript I.
Information Technology Center Hany Abdelwahab Computer Specialist.
Web Page Behavior IS 373—Web Standards Todd Will.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Javascript and the Web Whys and Hows of Javascript.
4.1 JavaScript Introduction
Introduction to JavaScript Dr. John P. Abraham University of Texas – Pan American.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
Scripting Languages.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
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,
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)
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
An Introduction to JavaScript Summarized from Chapter 6 of “Web Programming: Building Internet Applications”, 3 rd Edition.
JavaScript - A Web Script Language Fred Durao
JS Basics 1 Lecture JavaScript - Basics. JS Basics 2 What is JavaScript JavaScript is a “simple”, interpreted, programming language with elementary object-
JavaScript Adding active content to websites. Goals Understand structure of JavaScript Understand rules of coding Add active content to WebPages Add functions.
1 JavaScript
Introduction to JavaScript CS101 Introduction to Computing.
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
1 A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 4 JavaScript and.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
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,
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part One.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
© 2007 D. J. ForemanJS-1 A Light Introduction for Non-programmers JavaScript for Beginners.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Java Script About Java Script Document Object Model Incorporating JavaScript Adding JavaScript to HTML Embedding a Javascript External Scripts Javascript.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
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.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
Introduction to JavaScript. Introduction What is it? How does it work? What is Java? Learning JavaScript JavaScript Statements JavaScript and HTML forms.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Copyright © Terry Felke-Morris Web Development & Design Foundations with HTML5 8 th Edition CHAPTER 14 KEY CONCEPTS 1 Copyright.
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
Module 1 Introduction to JavaScript
CHAPTER 10 JAVA SCRIPT.
“Under the hood”: Angry Birds Maze
Donna J. Kain, Clarkson University
Web Development & Design Foundations with HTML5 7th Edition
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
T. Jumana Abu Shmais – AOU - Riyadh
Introduction to JavaScript
CS105 Introduction to Computer Concepts
Tutorial 10: Programming with javascript
Web Programming– UFCFB Lecture 13
Web Programming and Design
CS105 Introduction to Computer Concepts JavaScript
Presentation transcript:

AdvWeb-1/29 DePaul University SNL 262 Advanced Web Page Design Introduction To JavaScript - II Instructor: David A. Lash

AdvWeb-2/29 What Is JavaScript u As WWW matured designers needed more control over pages. – HTML specification was not adequate enough u Netscape invented JavaScript – In 1995, Netscape's LiveScript became JavaScript with a joint announcement by Sun and Netscape. (Started in Netscape 2.0) – JavaScript is similar (but different) from C, C++, and Java.

AdvWeb-3/29 What Is JavaScript u As WWW matured designers needed more control over pages. – HTML specification was not adequate enough – Netscape invented JavaScript u A programming language used to make web pages more interactive. Using JavaScript you can – add scrolling or changing messages – validate forms and make calculations – display alert messages or custom messages animate images – detect the browser version and react accordingly – set and detect "cookies" – detect plug-ins and react accordingly. – test for and react to plug-in presence – create pages on-the-fly

AdvWeb-4/29 An Extension To HTML u JavaScript extends HTML as such – can be a partial line or a single line embedded within HTML – can be several lines or even pages of lines – Is easy to make changes David Lash Here is my home page document.write("Last Updated on " + document.lastModified );

AdvWeb-5/29 An Extension To HTML

AdvWeb-6/29 An Extension To HTML u JavaScript extends HTML as such – can be a partial line or a single line embedded within HTML – can be several lines or even pages of lines – Is easy to make changes Your browser doesn’t support JavaScript. Please update your browser version

AdvWeb-7/29 JavaScript Versions

AdvWeb-8/29 JavaScript Is Not... u VBScript - Microsoft alternative to JS – based on visual basic – a microsoft supported language – IE only, no Netscape

AdvWeb-9/29 JavaScript Is Not... u CGI - a specification that allows for HTML pages to interface with programs on web servers. (Pgms can be lots of different languages)

AdvWeb-10/29 JavaScript Is Not... u Java - A programming language developed by Sun that creates applets that can be inserted into web pages. (runs on IE and NS). ed.html u ActiveX - Microsoft alternative that allows Windows programs to run within a web page. – Compiled and placed on web server – not as easy as JS – Only works with IE and windows platforms

AdvWeb-11/29 Getting Started With JavaScript u In HTML, you interlace your text you want to display with HTML TAGs – Know exactly how your document will display. – Little if any interaction with user. Page does not react, or change. u JavaScript you have additional tools – Variables - A data element that can hold values of numbers or strings. u For example, x=0 y=3+3 z="apple” – Control Structures - These are language statements that allow you to test and loop and detect when certain events occur. u For example, if ( x == 0 ) { do something }

AdvWeb-12/29 Getting Started With JavaScript... u JavaScript you have additional tools... – Event Handling - These constructs let you take control when the user does something specific. These specific events include things like, click an area ( u onclick(do something)), u onSumbit(do something else), u onLoad(does something). – Object manipulation and use - Javascript has a series of objects available to examine and manipulate u Available objects includes things like windows, forms, form elements.

AdvWeb-13/29 Getting Started With JavaScript... u JavaScript you have additional tools... – Object Properties Manipulation and Use - – Objects have properties that you can manipulate and look at: u For example, window.status, document.image.name. – You can look at these properties like any other variable. – Methods Associated with Objects - allow you to take action on the object. u For example, document.write(), forms.elements.window.click(), windows.open()

AdvWeb-14/29 Getting Started With JavaScript... Really u A simple HTML program A First Page A Simple Header This is not a very interesting page See: tml.html tml.html

AdvWeb-15/29 Getting Started With JavaScript... Really u A simple HTML program with JavaScript A First Page A Simple Header This is not a very interesting page document.write("Here are 3 things I like"); document.write(" Baseball Hot Dogs Apple Pie "); See: html.html html.html Start and end script Writes out to html document

AdvWeb-16/29 What Happens When There Is A JavaScript Error? u Suppose the HTML missing a quote mark in the 2nd document.write u Type JavaScript: word in the URL portion of the browser to display the JavaScript syntax error. A First Page A Simple Header This is not a very interesting page document.write("Here are 3 things I like"); document.write(" Baseball Hot Dogs Apple Pie ); Missing a quote (“) See: exampleshttp:// examples /2_ Simple3html.html

AdvWeb-17/29 Introduction To Programming - Variables (Chapt 6) u In JavaScript & programming languages varaibles are used to remember and manipulate values: This includes – Number values u x=2 u y=3.14 – Text Values u Z=“John Doe” u X=“Happy” u With Numbers can create simple expressions: A=2+2 B=A+3

AdvWeb-18/29 Introduction To Programming - Variables (Chapt 6) u What would the following do? A First Page A Simple Header This is not a very interesting page X=3 y=2 z=2+X+Y document.write(”Z=”, Z); See: 2_example2.html

AdvWeb-19/29 Introduction To Programming - Variable Names (Chapt 6) Some rules on Variable Names: u They are case sensitive: – (myName != Myname != MyName ) – They must begin with upper or lower case letter or – 1more is not a good variable name, – test_1 is OK u They cannot contain a space. – Response_time is OK – response time is not a good variable name u No limit on the length of variable names but must fit into1 line. u These are valid variable names: – total_number_of_fish – LastInvoiceNumber – temp1 – a – _variable1

AdvWeb-20/29 Introduction To Programming - Variable Types (Chapt 6) u JavaScript takes care of converting between the types: A First Page A Simple Header This is not a very interesting page X=3.14 Y=2 Z=2+X+Y document.write("Z=", Z); 2_example3.html

AdvWeb-21/29 Expressions Using *, /, +, - u Use *, /, +, - for expressions – x=x*1 – x=x/y – z=z-1 u Use parenthesis to clarify precedence – x=(x*2)/2 – x=(x+2+3)/(14-2) u Normal precedence ordering is multiplication, division, addition, subtraction 4* /6 12/4* *6 4*2*6/3+2

AdvWeb-22/29 Precedence Example A First Page A Simple Header This is not a very interesting page X=2 Y=4 W=8 Z1=X+Y/W Z2=(X+Y)/W Z3=X*Y/W document.write("Z1=", Z1, " "); document.write("Z2=", Z2, " "); document.write("Z3=", Z3, " ");

AdvWeb-23/29 Remainder and Other Stuff u Other Remainder Uses the % operator – 3%4; - put remainder of 3/4 in lines u Here is another example: A First Page A Simple Header This is not a very interesting page X=2 Y=4 W=8 Z1=W%(X+Y) Z2=(X*Y)%W document.write("Z1=", Z1, " "); document.write("Z2=", Z2, " ");

AdvWeb-24/29 Other Stuff u What does this code do? A First Page A Simple Header This is not a very interesting page X=2 Y=4 W=8 Z1=W%(X+Y) Z2=(Z3)/8 document.write("Z1=", Z1, " "); document.write("Z2=", Z2, " "); >

AdvWeb-25/29 Simple String Manipulation u What does this code do? A First Page A Simple Header This is not a very interesting page X="Apple" Y="Jack" Z1=X+Y Z2=X+" "+Y document.write("Z1=", Z1, " "); document.write("Z2=", Z2, " ");

AdvWeb-26/29 Operator Table

AdvWeb-27/29 2 Other Very Useful Methods Window Alert - – window.alert("your message here"); u writes an alert pop-up box to end-user from browser. For Example Using Variables window.alert("Hey welcome to Advance Website!"); window.alert("Thats right I said ADVANCED Website Design"); t1.html

AdvWeb-28/29 2 Other Very Useful Methods Window Prompt - – userinput = window.prompt("Message in pop-up"); sets a pop-up box with message and gets the user input and sets it to userinput. Using Varaibles name=window.prompt("Hey What Is Your Name"); document.write("The name was", name ); number=window.prompt("Pick a number->"); document.write("The number tme 50=", number*50 ); u tml tml

AdvWeb-29/29 Example 5.2 From Book Customized home page first = window.prompt("Enter your first name."); last = window.prompt("Enter your last name."); title = window.prompt("Enter a page title."); document.write(" " + title + " "); document.write(" By " + first + " " + last + " "); This page is under construction. u See: l ist5-2.html l ist5-2.html