1 rfXcel Confidential Copyright 2007 Web Technology JavaScript 12/10/07.

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
The Web Warrior Guide to Web Design Technologies
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
JavaScript Forms Form Validation Cookies CGI Programs.
Tutorial 6 Forms Section A - Working with Forms in JavaScript.
CST JavaScript Validating Form Data with JavaScript.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
4.1 JavaScript Introduction
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
JavaScript and The Document Object Model MMIS 656 Web Design Technologies Acknowledgements: 1.Notes from David Shrader, NSU GSCIS 2.Some material adapted.
JavaScript & jQuery the missing manual Chapter 11
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
JavaScript - Document Object Model. Bhawna Mallick 2 Unit Plan What is DOM and its use? Hierarchy of DOM objects. Reflection of these objects in an HTML.
Server vs Client-side validation. JavaScript JavaScript is an object-based language. JavaScript is based on manipulating objects by modifying an object’s.
Introduction to JavaScript Dr. John P. Abraham University of Texas – Pan American.
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
HTML Forms and Scripts. Session overview What are forms? Static vs dynamic Client-side scripts –JavaScript.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Execution Environment for JavaScript " Java Script Window object represents the window in which the browser displays documents. " The Window object provides.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
© 2000 – All Rights Reserved - Page 1 Introduction to JavaScript Programming Part Two.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaScript Fundamentals.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
JSP Java Server Pages Softsmith Infotech.
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,
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
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.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
Scripts Chapter Scripts Small programs used to add interactivity to your web pages The backbone of Dynamic HTML (DHTML) Most scripts are written.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
JavaScript - A Web Script Language Fred Durao
AJAX Compiled from “AJAX Programming” [Sang Shin] (Asynchronous JavaScript and XML)
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
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.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
AJAX Asynchronous JavaScript & XML A short introduction.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Event Handling & AJAX IT210 Web Systems. Question How do we enable users to dynamically interact with a website? Answer: Use mouse and keyboard to trigger.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
JavaScript II ECT 270 Robin Burke. Outline Functions Events and event handling Form validation.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript and Ajax Week 10 Web site:
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Open Solutions for a Changing World™ Eddy Kleinjan Copyright 2005, Data Access WordwideNew Techniques for Building Web Applications June 6-9, 2005 Key.
DHTML.
Section 17.1 Section 17.2 Add an audio file using HTML
Web Development & Design Foundations with HTML5 7th Edition
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript Introduction
DHTML Javascript Internet Technology.
DHTML Javascript Internet Technology.
Tutorial 10: Programming with javascript
Presentation transcript:

1 rfXcel Confidential Copyright 2007 Web Technology JavaScript 12/10/07

2 rfXcel Confidential Copyright 2007 JavaScript Overview A Scripting language for web Written by Netscape in 1995 Netscape Navigator 2.0 –JavaScript 1.0 Object Based Language – Not Compiled Language – Case sensitive Can be embedded with HTML tags or separately JavaScript Interacts with Document Object Model of Browser DOM Not Totally Standardized JavaScript allows for interactivity

3 rfXcel Confidential Copyright 2007 JavaScript and HTML Runs in Browser Add to HTML with Script Tag document.write("This text was written with JavaScript!");

4 rfXcel Confidential Copyright 2007 JavaScript and HTML My First Java Script This is a line of code before the script <!-- var rightNow = new Date(); document.write("This text was written with JavaScript! "); document.write("It is now!" + rightNow); //--> This is a line of code after the script

5 rfXcel Confidential Copyright 2007 JavaScript and HTML HTML Script Tag may call an external file External files supported in Netscape and Microsoft Internet Explorer 4.0 and above Single lien comment –// document.write("This text was written with JavaScript!"); Multi-line comment –<!-- document.write("This text was written with JavaScript!"); -->

6 rfXcel Confidential Copyright 2007 JavaScript and HTML document.write("This text was written with JavaScript!"); document – javascript object write – method contained in the object (“This text….”) – string argument passed to method Place javascript that outputs directly to the page in the BODY of the HTML page Place javascript that does not output to the page in the HEAD section of the HTML page document.name – named element in document document.images – array of images document.forms – array of forms Ways to access window, cookies, etc.

7 rfXcel Confidential Copyright 2007 JavaScript and HTML Where Do I Put Them –Scripts in the body section will execute while the page loads –Scripts in the head section will be executed when called –You can place an unlimited number of scripts in your document, so you can have scripts in both the body and the head section.

8 rfXcel Confidential Copyright 2007 JavaScript Objects Reference WebsiteReference Website WindowScreenObjectLayerFormButton TextareaResetNumberImageFileUploadBoolean TextRegExpNavigatorHistoryEventArray SubmitRadioMathHiddenDocumentArea StringPasswordLocationFunctionDateApplet ScreenOptionLinkFrameCheckboxAnchor

9 rfXcel Confidential Copyright 2007 JavaScript Objects Hierarchy Standard Objects –Window Location History Frames Navigator – Plugin – Mime-type –Document

10 rfXcel Confidential Copyright 2007 JavaScript Objects Hierarchy Standard Objects –Window –Document Anchor Applet Link and Area Image Form

11 rfXcel Confidential Copyright 2007 JavaScript Objects Hierarchy Standard Objects –Window –Document Form – Button – Checkbox – FileUpload – Hidden – Password – Radio – Reset – Select – Submit – Text – Textarea

12 rfXcel Confidential Copyright 2007 JavaScript Methods Methods are functions and procedures used to perform an operation on an object, variable, or constant. With the exception of built-in functions, methods must be used with an object: object.method() Method Reference cript/quickref/js_methods.html

13 rfXcel Confidential Copyright 2007 JavaScript Properties A JavaScript object has properties associated with it. You access the properties of an object with a simple notation: objectName.propertyName Different Objects have a different set of properties Property Reference

14 rfXcel Confidential Copyright 2007 JavaScript Events JavaScript applications are typically event-driven. Events are actions that occur, usually as a result of something the user does. For example, a button click is an event, as is giving focus to a form element. You can define Event handlers, scripts that are automatically executed when an event occurs W3Schools Reference DevGuru Reference

15 rfXcel Confidential Copyright 2007 JavaScript Events Events apply to HTML tags as follows: –Focus, Blur, Change events: text fields, textareas, and selections –Click events: buttons, radio buttons, checkboxes, submit buttons, reset buttons, links –Select events: text fields, textareas –MouseOver event: links

16 rfXcel Confidential Copyright 2007 JavaScript Events EventOccurs when...Event Handler blurUser removes input focus from form elementonBlur clickUser clicks on form element or linkonClick changeUser changes value of text, textarea, or select elementonChange focusUser gives form element input focusonFocus loadUser loads the page in the NavigatoronLoad mouseoverUser moves mouse pointer over a link or anchoronMouseOver selectUser selects form element's input fieldonSelect submitUser submits a formonSubmit unloadUser exits the pageonUnload

17 rfXcel Confidential Copyright 2007 AJAX –Asynchronous Javascript And Xml. –The JavaScript communicates with the server using XMLHttpRequest, receives a response in the form of XML from the server side component, which is used by the JavaScript to manipulate the HTML to present data to the user.

18 rfXcel Confidential Copyright 2007 AJAX Four Steps to implement AJAX –Setting up the XMLHttpRequest. –Calling the server-side component. –Generate the XML response. –Registering and implementing call-back handler and at the server side.

19 rfXcel Confidential Copyright 2007 AJAX Setting up the XMLHttpRequest. var xmlHttp; if(window.ActiveXObject) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest) { xmlHttp=new XMLHttpRequest(); }

20 rfXcel Confidential Copyright 2007 AJAX Calling the server-side component i. setRequestHeader xmlHttp.setRequestHeader("Content-Type", "application/x- www-form-urlencoded; charset=UTF-8"); ii. open xmlHttp.open("GET",” +user, true); iii.send var params=”user=”+user+”&pass=”+pass; xmlHttp.send(params)

21 rfXcel Confidential Copyright 2007 AJAX Generate the XML response. response.setContentType("text/xml"); response.getWriter().write(" true ");

22 rfXcel Confidential Copyright 2007 AJAX Registering and implementing call-back handler and at the server side. xmlHttp.onreadystatechange=handleStateChange; function handleStateChange(){ if(xmlHttp.readyState==4) { if(xmlHttp.status==200) { document.getElementById("results").innerHTML=xmlHttp.resp onseText; } else { alert("Error "+ xmlHttp.status +":"+xmlHttp.statusText); } } }

23 rfXcel Confidential Copyright 2007 AJAX Status of the Request. –0: The request is uninitialized (before you've called open()). –1: The request is set up, but not sent (before you've called send()). –2: The request was sent and is in process (you can usually get content headers from the response at this point).

24 rfXcel Confidential Copyright 2007 AJAX Status of the Request. –3: The request is in process; often some partial data is available from the response, but the server isn't finished with its response. –4: The response is complete; you can get the server's response and use it.