Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I HTML DOM part I Jongwook.

Slides:



Advertisements
Similar presentations
Document Object Model (DOM) JavaScript manipulation of the DOM.
Advertisements

HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Lesson 12- Unit L Programming Web Pages with JavaScript.
Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I HTML DOM part II Jongwook.
Tutorial 16 Working with Dynamic Content and Styles.
Computer Information Systems Information Systems California State University Los Angeles Jongwook Woo CIS 561 Design of an E-Commerce Site XML Validation.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I Javascript Jongwook Woo,
Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I JQuery Part I Jongwook Woo,
Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I HTML 5 Jongwook Woo, PhD.
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.
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.
JS: Document Object Model (DOM)
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Lecture 2 : Understanding the Document Object Model (DOM) UFCFR Advanced Topics in Web Development II 2014/15 SHAPE Hong Kong.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
A really fairly simple guide to: mobile browser-based application development (part 4, JQuery & DOM) Chris Greenhalgh G54UBI / Chris Greenhalgh.
UFCEWT-20-3 Advanced Topics in Web Development Lecture 4 : JavaScript, Browsers & the HTML DOM-API.
DOM and JavaScript Aryo Pinandito.
Lecture 11 – DOM Scripting SFDV3011 – Advanced Web Development Reference: 1.
Working with the XML Document Object Model ©NIITeXtensible Markup Language/Lesson 7/Slide 1 of 44 Objectives In this lesson, you will learn to: *Identify.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
5.2 DOM (Document Object Model). 2 Motto: To write it, it took three months; to conceive it three minutes; to collect the data in it — all my life. —F.
Computer Information Systems Information Systems California State University Los Angeles Jongwook Woo CIS 561 Design of an E-Commerce Site Introduction.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
XHTML and CSS Session 1 Intro, (X)HTML, CSS, W3C, browsers, webpage, structure, tags, attributes, elements, web development process, basic XHTML elements.
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.
XP Tutorial 16 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
IS2802 Introduction to Multimedia Applications for Business Lecture 1: Introduction to IS2802 Rob Gleasure
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 10.
1 Dr Alexiei Dingli XML Technologies SAX and DOM.
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.
Advanced DOM Builds on last presentation on DOM Allows you to dynamically create elements and position them on a page DOM methods/properties are W3C standard.
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.
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.
CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.
DOM (Document Object Model) - Parsing and Reading HTML and XML -
School of Computing and Information Systems CS 371 Web Application Programming JavaScript - DOM Modifying the Page from within.
Advanced DOM Builds on last presentation on DOM Allows you to dynamically create elements and position them on a page DOM methods/properties are W3C standard.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Document Object Model (DOM). Outline  Introduction of DOM  Overview of DOM  DOM Relationships  Standard DOM.
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
Document Object Model.  The XML DOM (Document Object Model) defines a standard way for accessing and manipulating XML documents.  The DOM presents an.
Create Element, Remove Child. The Document Tree Document Element Root Element Element Element Element Element Text: HelloWorld Attribute “href”
JS: Document Object Model (DOM) DOM stands for Document Object Model, and allows programmers generic access to: DOM stands for Document Object Model, and.
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
XML DOM Week 11 Web site:
XP Tutorial 10 New Perspectives on JavaScript, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
1 The Document Object Model. 2 Objectives You will be able to: Describe the structure of the W3C Document Object Model, or DOM. Use JavaScript to access.
THE DOM.
DHTML.
Programming Web Pages with JavaScript
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Scripting the DOM MIS 3502, Fall 2016 Jeremy Shafer Department of MIS
CGS 3066: Web Programming and Design Spring 2017
Applied Online Programming
Intro to JavaScript CS 1150 Spring 2017.
Document Object Model (DOM): Objects and Collections
Week 11 Web site: XML DOM Week 11 Web site:
The Document Object Model
More Sample XML By Sadia Anjum.
CHAPTER 7 JavaScripts & HTML Documents
Introduction to Programming the WWW I
Working with Dynamic Content and Styles
Document Object Model (DOM): Objects and Collections
JavaScript and the DOM MIS 2402 Maxwell Furman Department of MIS
Presentation transcript:

Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I HTML DOM part I Jongwook Woo, PhD California State University, Los Angeles Computer Information System Department

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Content nDOM Home nDOM Intro nDOM Nodes nDOM Node Tree nDOM Methods

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System HTML DOM ndefines a standard way for accessing and manipulating HTML documents. nThe DOM presents an HTML document as a tree-structure.

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System What is DOM? nThe DOM is a W3C (World Wide Web Consortium) standard. mdefines a standard for accessing documents like HTML and XML: mallows programs and scripts to dynamically access –and update the content, structure, and style of a document nThe DOM is separated into 3 different parts / levels: mCore DOM - standard model for any structured document mXML DOM - standard model for XML documents mHTML DOM - standard model for HTML documents nThe DOM defines mthe objects and properties of all document elements, –and the methods (interface) to access them.

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System What is DOM? nThe HTML DOM ma standard for how to get, change, add, or delete HTML elements nDOM Nodes meverything in an HTML document is a node. ma document node –The entire document is man element node –Every HTML element is mtext nodes –The text in the HTML elements are man attribute node –Every HTML attribute is mcomment nodes –Comments are

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System DOM Example DOM Tutorial DOM Lesson one Hello world! nThe root node in the HTML above is. mThe node has two child nodes; and. mThe node holds a node. mThe node holds a and node.

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Text Nodes nText is Always Stored in Text Nodes mNo element node to contain text. mIn this example: – DOM Tutorial, –the element node, holds a text node with the value "DOM Tutorial". –"DOM Tutorial" is not the value of the element!

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System HTML DOM Node Tree nThe DOM presents an HTML document as a tree-structure.

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System HTML DOM Node Tree (Cont’d) nNode Parents, Children, and Siblings mThe nodes have a hierarchical relationship to each other. mThe terms parent, child, and sibling are used to describe the relationships. –Parent nodes have children. nthe root mIn a node tree, the top node is called mEvery node, except the root, has exactly one parent node nA node can have any number of children mA leaf is a node with no children nSiblings are nodes with the same parent mChildren on the same level are called siblings (brothers or sisters).

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System DOM Node Tree Example DOM Tutorial DOM Lesson one Hello world! nThe node has no parent node; it is the root node mThe parent node of the and nodes is the node –The parent node of the "Hello world!" text node is the node nThe node has two child nodes; and mThe node has one child node; the node –The node also has one child node; the text node "DOM Tutorial" mThe and nodes are siblings, and both child nodes of

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System DOM Node Tree Example (Cont’d) DOM Tutorial DOM Lesson one Hello world! nFirst Child - Last Child mthe element is the first child of the element, mand the element is the last child of the element –the element is the first child of the element, –and the element is the last child of the element

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Properties and Methods ndefine the programming interface of the HTML DOM. nThe nodes of DOM can be accessed mwith JavaScript or other programming languages. nProperties mreferred to as something that is (i.e. the name of a node). nMethods mreferred to as something that is done (i.e. remove a node). nHTML DOM Properties: x is a node object (HTML element) mx.innerHTML - the text value of x mx.nodeName - the name of x mx.nodeValue - the value of x mx.parentNode - the parent node of x mx.childNodes - the child nodes of x mx.attributes - the attributes nodes of x

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System HTML DOM Methods nSome DOM methods: x is a node object mx.getElementById(id) - get the element with a specified id mx.getElementsByTagName(name) - get all elements with a specified tag name mx.appendChild(node) - insert a child node to x mx.removeChild(node) - remove a child node from x nThe innerHTML Property mThe easiest way to get or modify the content of an element minnerHTML is not a part of the W3C DOM specification. –However, it is supported by all major browsers. museful for returning or replacing the content of HTML elements (including and ),

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System HTML DOM Example nThe following code gets the innerHTML (text) from the element with id="intro": Hello World! txt=document.getElementById("intro").innerHTML; document.write(" The text from the intro paragraph: " + txt + " "); n getElementById is a method, mwhile innerHTML is a property.

Jongwook Woo CSULA Jongwook Woo Computer Information System Information System Childe Node Example nchildNodes and nodeValue properties mto get the content of an element. mThe following code gets the value of the element with id="intro": Hello World! txt=document.getElementById("intro").childNodes[0].nodeValue; document.write(" The text from the intro paragraph: " + txt + " ");