CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.

Slides:



Advertisements
Similar presentations
XML IV. The Document Object Model The Document Object model is a hierarchical structure of an XML document. It provides a means for accessing, and manipulating.
Advertisements

Working with Forms. how are forms manipulated? the document object contains an array of forms objects, one for each form, in document order –forms[] any.
Sue Wills July Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
A really fairly simple guide to: mobile browser-based application development (part 1) Chris Greenhalgh G54UBI / Chris Greenhalgh
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Lesson 12- Unit L Programming Web Pages with JavaScript.
HTML5 and CSS3 Illustrated Unit B: Getting Started with HTML
Tutorial 16 Working with Dynamic Content and Styles.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
XML Primer. 2 History: SGML vs. HTML vs. XML SGML (1960) XML(1996) HTML(1990) XHTML(2000)
Upgrading to XHTML DECO 3001 Tutorial 1 – Part 1 Presented by Ji Soo Yoon 19 February 2004 Slides adopted from
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.
JavaScript and The Document Object Model MMIS 656 Web Design Technologies Acknowledgements: 1.Notes from David Shrader, NSU GSCIS 2.Some material adapted.
Week 1.  Phillip Chee   Ext.1214 
HTML DOM.  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  The DOM presents an HTML document as a tree- structure.
CS 299 – Web Programming and Design Introduction to HTML.
Lecture 11 – DOM Scripting SFDV3011 – Advanced Web Development Reference: 1.
JavaScript is a client-side scripting language. Programs run in the web browser on the client's computer. (PHP, in contrast, is a server-side scripting.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message.
Client side web programming Introduction Jaana Holvikivi, DSc. School of ICT.
INTRODUCTION. What is HTML? HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML is not a programming language,
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
How do I use HTML and XML to present information?.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
JavaScript - A Web Script Language Fred Durao
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 10.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Review of the DOM Node properties and methods Some ways of accessing nodes Appending, copying and removing nodes Event handling – Inline – Scripting –
 defined as Extensible Markup Language (XML) is a set of rules for encoding documents  Defines structure and data.
1 The Information School of the University of Washington Nov 1fit dom © 2006 University of Washington Document Object Model (DOM)
HTML JAVASCRIPT. CONTENTS Javascript Example NOSCRIPT Tag Advantages Summary Exercise.
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.
XML CSC1310 Fall HTML (TIM BERNERS-LEE) HyperText Markup Language  HTML (HyperText Markup Language): December  Markup  Markup is a symbol.
JavaScript Overview Developer Essentials How to Code Language Constructs The DOM concept- API, (use W3C model) Objects –properties Methods Events Applications;
DOM (Document Object Model) - Parsing and Reading HTML and XML -
INTRODUCTION JavaScript can make websites more interactive, interesting, and user-friendly.
Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 9.
Document Object Model (DOM). Outline  Introduction of DOM  Overview of DOM  DOM Relationships  Standard DOM.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I HTML DOM part I Jongwook.
Document Object Model.  The XML DOM (Document Object Model) defines a standard way for accessing and manipulating XML documents.  The DOM presents an.
CHAPTER TWO HTML TAGS. 1.Basic HTML Tags 1.1 HTML: Hypertext Markup Language  HTML stands for Hypertext Markup Language.  It is the markup language.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
XML DOM Week 11 Web site:
Internet & World Wide Web How to Program, 5/e.  JavaScript events  allow scripts to respond to user interactions and modify the page accordingly  Events.
HTML5 and CSS3 Illustrated Unit B: Getting Started with HTML.
XP Tutorial 10 New Perspectives on JavaScript, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
THE DOM.
DHTML.
Javascript and Dynamic Web Pages: Client Side Processing
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Unit M Programming Web Pages with
Unit M Programming Web Pages with
Week 11 Web site: XML DOM Week 11 Web site:
The Document Object Model
DHTML Javascript Internet Technology.
Introduction to JavaScript
More Sample XML By Sadia Anjum.
DHTML Javascript Internet Technology.
CHAPTER 7 JavaScripts & HTML Documents
Introduction to Programming the WWW I
Document Object Model (DOM): Objects and Collections
Introduction to Programming and JavaScript
Presentation transcript:

CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events

Overview Part 1: The Document Object Model How the browser “structures” your pages, HTML and JavaScript Part 2: JavaScript Events and Event Handlers How the browser can react to user input

Part 1: The Document “Object Model” DOM standard is set by the World Wide Web ConsortiumWorld Wide Web Consortium Historically there have been 3 standards: Levels 0,1 and 2. Level 2 is current. The standard is described here: /introduction.html /introduction.html

The Document “Object Model” The Document Object Model (DOM) is an application programming interface (API) for valid HTML and well-formed XML documents.APIHTMLXML It defines the logical structure of documents and the way a document is accessed and manipulated.

An example Shady Grove Aeolian Over the River, Charlie Dorian

Model of the example Nodes

Tree Documents have a logical structure which branches like a tree Documents are modelled using objects (remember these from programming!) The “model” encompasses not only the structure of a document, but also its behaviour and the objects of which it is composed Models do not represent a data structure, they represent objects, which have functions and identity.

Parents and children Objects higher in the tree are parents to those below Objects lower down are children of those above Access is hierarchical, you have to access child objects via the parent object

Another example This is the title This is a sample paragraph. Draw the tree now to understand the relationships – we will use it later

Parent nodes and child nodes Document HTML Body Paragraph Head Child of “document” Child of “HTML” Parent of “HTML” Parent of “Head” and “Body” Parent of “paragraph” Child of “body” Title Child of “head” Parent of “title”

An Object is: A scriptable entity maintained in the browser’s memory when a document is loaded Described by properties, methods, collections (arrays) of nested items, and event handlers

Examples of objects Document represents the entire HTML or XML document it is the root of the document treeroot provides the primary access to the document's data elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a document

Why do I need to know about this? Remember that a Document Object is a scriptable entity To be able to make our HTML interactive using JavaScript, we need to have objects to work on We need to know what the entities are So we can script them!

Examples of scriptable objects Document Window Body H1 and its friends Paragraph Image Form Table All of the structural elements have attributes (properties) and can be manipulated by methods

Our example again: This is the title This is a sample paragraph.

Scripting alert(document.documentElement.lastChild.firstChild.tagName); Will produce a JavaScript alert showing P document.documentElement - gives the page's HTML tag..lastChild - gives the BODY tag..firstChild - gives the first element in the BODY..tagName - gives that element's tag name, "P" in this case.

Can we do something useful now please? To sum up so far (Part 1) JavaScript can make use of the objects within a document You can access these objects and manipulate them using simple statements This is why JavaScript is NOT a programming language It can only use the objects that are recognised in the browser’s “model” – it can’t format your hard drive, for example!