© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
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
© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University
Server-Side vs. Client-Side Scripting Languages
© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University
1 HCI 201 JavaScript - Part 1. 2 Static web pages l Static pages: what we have worked with so far l HTML tags tell the browser what to do with the content.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
LBSC 690 Session #10 Programming, JavaScript Jimmy Lin The iSchool University of Maryland Wednesday, November 5, 2008 This work is licensed under a Creative.
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
LBSC 690: Session 10 Programming, JavaScript Jimmy Lin College of Information Studies University of Maryland Monday, November 12, 2007.
Web Page Behavior IS 373—Web Standards Todd Will.
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.
© Anselm SpoerriDigital Media Production Digital Media Production Digital Media Production Anselm Spoerri PhD (MIT) Rutgers University
Languages in WEB Presented by: Jenisha Kshatriya BCM SS09.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
INTERNET APPLICATION DEVELOPMENT For More visit:
L. Grewe LAMP, WAMP and... Motivaiton Basic Web Systems with Delivery of Static and Dynamic Web Pages html, css, media javascript (“dynamic” on client.
CISC474 - JavaScript 03/02/2011. Some Background… Great JavaScript Guides: –
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
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)
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
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 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.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Dynamic web content HTTP and HTML: Berners-Lee’s Basics.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
05 – Java Script (1) Informatics Department Parahyangan Catholic University.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
WHAT IS SERVER SIDE SCRIPTING? Server-side scripting is a web server technology in which a user's request is verified by running a script directly on the.
1 JavaScript in Context. Server-Side Programming.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Java Script About Java Script Document Object Model Incorporating JavaScript Adding JavaScript to HTML Embedding a Javascript External Scripts Javascript.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
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,
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
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.
JavaScript and Ajax (Ajax Tutorial)
Introduction to Dynamic Web Programming
Tutorial 10 Programming with JavaScript
Web Development & Design Foundations with HTML5 7th Edition
PHP Introduction.
LAMP, WAMP and.. L. Grewe.
WEB PROGRAMMING JavaScript.
PHP.
Tutorial 10 Programming with JavaScript
Tutorial 10: Programming with javascript
Information Technologies Anselm Spoerri PhD (MIT)
Presentation transcript:

© Anselm SpoerriInfo + Web Tech Course Information Technologies Info + Web Tech Course Anselm Spoerri PhD (MIT) Rutgers University

© Anselm SpoerriInfo + Web Tech Course Lecture 7 - Overview Dynamic Web –JavaScript | PHP | MySQL | Apache Programming Concepts JavaScript and Document Object Model (DOM) –Data Types, Variables, Operators, Statements –Function and Control Structures –Document Object Model (DOM) –Image Rollovers Lectures – Week 7 Content

© Anselm SpoerriInfo + Web Tech Course Web Pages Created So Far Static HTML Pages –Same each time Want Interactive or Dynamic Web Pages –Depending on browser, time of day or user behavior or … different appearance –Processing user inputs data via HTML forms –Need some sort of Web programming (JavaScript, PHP)

© Anselm SpoerriInfo + Web Tech Course Basic Client/Server Request/Response Sequence

© Anselm SpoerriInfo + Web Tech Course Dynamic Client/Server Request/Response Sequence $query $result

© Anselm SpoerriInfo + Web Tech Course Dynamic Web 1.JavaScript –Client-side scripting access to elements of HTML document –Perform data handling and web server requests in background 2.PHP –Server-side scripting –Open source, simplicity and built-in links to MySQL database 3.MySQL –Open-source Relational Databases that supports structured queries and is free to use and install on web servers 4.Apache Server –Open source server software that serves up HTML, media files etc PHP handles main work on web server, MySQL manages data, and JavaScript looks after web page presentation. JavaScript can also talk with your PHP code on the web server whenever it needs to update something (either on the server or on the web page).

© Anselm SpoerriInfo + Web Tech Course Dynamic Web Page – Gmail Signup Page

© Anselm SpoerriInfo + Web Tech Course Dynamic Web, AJAX and Web 2.0 Dynamic Web –JavaScript specifies web page interactivity and presentation –PHP handles main work on web server and retrieves data –MySQL manages and stores data –JavaScript performs data handling & server requests in background –JavaScript can also talk with PHP code on the web server to update data or presentation (either on server or web page) JavaScript used for AJAX and Web 2.0 “Asynchronous JavaScript and XML” –Ajax is the main process behind what is now known as Web 2.0 –Process of accessing the web server in the background Setups used for Developing Dynamic Web Services WAMP = Windows, Apache, MySQL, and PHP MAMP = Mac, Apache, MySQL, and PHP LAMP = Linux, Apache, MySQL, and PHP

© Anselm SpoerriInfo + Web Tech Course Key Programming Concepts data types numbers, text, boolean (true, false) variable = container of data array = collection of data organized in a sequence statement = combination of variables, operators and data  group of statements  function = collection of statements to perform specific task perform test: true or false if (test) then for loop: where do we start? when are done? how to continue?

© Anselm SpoerriInfo + Web Tech Course Programming Concepts – Overview Data Types : such as numbers, text, boolean (true, false) ‒ Integer | Boolean | Character | String | Floating-Point ‒ Array: [5, 4, 7] (use FOR loop to examine each array item) Variable : is way to symbolically to refer to data content ‒ scores = [5, 4, 7]; Operators : can be used to perform built-in operations ‒ 5 +5; (where + is addition operator) Statement : combination of variables, operators and data ‒ total = 12 * monthly_average;

© Anselm SpoerriInfo + Web Tech Course Programming Concepts – Overview Function : collection of statements to perform specific task function add_scores (score1, score2) { return (score1 + score2); } total = add_scores (3, 4); Conditional Programming used so that operations are performed only if certain condition is met: ‒ IF test (only do something if certain condition is true) ‒ FOR loop (keep doing something only if certain condition is true) ‒ WHILE loop (keep doing something until certain condition not true anymore) Debugging code is essential part of programming... chasing typos, missing parentheses :)

© Anselm SpoerriInfo + Web Tech Course JavaScript –Client-side scripting language –Programs embedded as plain text in HTML of Web page, … –Since text, viewable to the world and for security reasons, scripts are limited in what they can do –Browser executes program as it loads page, integrating dynamic output of program with static content of HTML –Used to access to elements of HTML document. –Validate form data –Create dynamic user interaction such as checking address validity in input forms and interactive page elements … –Major implementation differences between different browsers.

© Anselm SpoerriInfo + Web Tech Course JavaScript – Some Uses Display information based on Time of Day JavaScript can check the computer's clock and pull the appropriate data based on the clock information. Detect Visitor's Browser this lecture JavaScript can be used to detect the visitor's browser, and load another page specifically designed for that browser. Validate Forms Data next lecture JavaScript can be used to validate form data at the client-side saving both the precious server resources and time. Add Interactivity to Website this lecture JavaScript can be set to execute when something happens, like when a user moves mouse over an image. Create Cookies JavaScript can store information on the visitor's computer and retrieve it automatically next time the user visits your page. Change Page Contents Dynamically JavaScript can change the display of content without the involvement of server programs. It can read and change the content of an HTML elements or move them around pages.

© Anselm SpoerriInfo + Web Tech Course JavaScript – Data Types, Variables, Operators, Statements Data Types – only three primitive data types Boolean: true, false Number: 5, 7.45 String: “Hello World” Variables = holds value of specific data type –sequences of letters, digits, and underscores –start with a letter or underscore –variables names are case-sensitive sci_550 = true; create variable sci_550 and set it to true var count = 100; create variable count and set it to 100 Operators count = count += 5 n++ count = 5 * temp “Hello” + “World” Statements Instructions end with semicolon … If missing, automatically inserted Assignment : total = earn1 – spend1 Return value from function: return total

© Anselm SpoerriInfo + Web Tech Course JavaScript – Arrays Array stores a sequence of items, accessible via an index items = new Array(10); // allocates space for 10 items items = new Array(); // if no size given, will adjust dynamically items = [0,0,0,0,0,0,0,0,0,0]; // can assign size & values [] items.length // the number of items in the array To access array element, use [index] for (i = 0; i < items.length; i++) { document.write(items[i] + " "); // displays elements }

© Anselm SpoerriInfo + Web Tech Course JavaScript : Function Functions function name (para1, para2, …) { … } Reusable code that consists of Collection of “statements” Takes one or more values as input “parameters” Returns “result” value function convertToCelsius(f) { var celsius = 5/9 * (f-32); return celsius; } var f = 50; c = convertToCelsius(f);

© Anselm SpoerriInfo + Web Tech Course JavaScript : Control Structures Control Structures Sequential top to bottom Conditional if (test) { … } else { … } Repetition for (i=0; i<100; i++) { … } Boolean Operators x == y true if x and y are equal x != y true if x and y are not equal x > ytrue if x is greater than y x <= y true if x is smaller than or equal to y x && ytrue if both x and y are true x || ytrue if either x or y is true !xtrue if x is false

© Anselm SpoerriInfo + Web Tech Course JavaScript – Stored Where Location of JavaScript External file External.js file: must not include any or tags script code Place code here to be available when page loads document.write(" Using JavaScript "); document.write("Hello World. Today is " + Date() ); Places h2 and “Hello World. Today is [current date]” in page where JavaScript is located Note: type="text/javascript" needed inside of tag in XHTML, but not in HTML5

© Anselm SpoerriInfo + Web Tech Course JavaScript Example Hello World document.write("Hello World") ; Your browser doesn't support or has disabled JavaScript. Tasks Change Text and apply h2 tag Add "+ Date()" to text being displayed Add paragraph before and after where JavaScript is inserted

© Anselm SpoerriInfo + Web Tech Course JavaScript and Document Object Model Document Object Model Platform- and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure and style of documents. Examples –document.write() –document.images[0] –document.links.linkname.href –document.getElementById("id") Reference, Tutorial and Examples jsref/default.asp See Lectures: Week 8 for more resources.

© Anselm SpoerriInfo + Web Tech Course Document Object Model url = document.links.linkname.href

© Anselm SpoerriInfo + Web Tech Course Access HREF using JavaScript and DOM Link Test SCI url = document.links.mylink.href ; // variable // document.write('The URL is ' + url); // access DOM //

© Anselm SpoerriInfo + Web Tech Course JavaScript – Detect Visitor's Browser document.write(navigator.appName); document.write(" "); document.write(navigator.appVersion); document.write(" "); document.write(navigator.userAgent); document.write(" "); More Info:

© Anselm SpoerriInfo + Web Tech Course Image Rollover JavaScript littlecat = new Image(143,83) littlecat.src = "real.jpg" bigcat = new Image(143,83) bigcat.src = "dream.jpg" <img src="real.jpg" name="catpic" onmouseover="document.catpic.src = bigcat.src" onmouseout="document.catpic.src = littlecat.src" />

© Anselm SpoerriInfo + Web Tech Course Accessing JavaScript error messages in different browsers Apple Safari Safari does not have an Error Console enabled by default, so the Firebug Lite JavaScript module will do what you need. To use it, add the following line of code somewhere before the tag in a document: Google Chrome Click the menu icon that looks like a page with a corner turned, then select Developer JavaScript Console. You can also use the following shortcut: Ctrl-Shift-J on a PC or Command-Shift-J on a Mac. Microsoft Internet Explorer Select Tools Internet Options Advanced, then uncheck the Disable Script Debugging box and check the Display a Notification about Every Script Error box. Mozilla Firefox Select Tools Error Console or use this shortcut: Ctrl-Shift-J on a PC or Command- Shift-J on a Mac. Opera Select Tools Advanced Error Console.