INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.

Slides:



Advertisements
Similar presentations
HTML: HyperText Markup Language Hello World Welcome to the world!
Advertisements

HTML5 and CSS3 Illustrated Unit B: Getting Started with HTML
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
AJAX (Asynchronous JavaScript and XML) Amit Jain CS 590 – Winter 2008.
Basics of HTML.
INTRODUCTION TO CLIENT-SIDE WEB PROGRAMMING ACM 511 ACM 262 Course Notes.
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.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
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)
Lecture 2 : Understanding the Document Object Model (DOM) UFCFR Advanced Topics in Web Development II 2014/15 SHAPE Hong Kong.
Lecture 11 – DOM Scripting SFDV3011 – Advanced Web Development Reference: 1.
HTML history, Tags, Element. HTML: HyperText Markup Language Hello World Welcome to the world!
Title, meta, link, script.  The title looks like:  The tag defines the title of the document in the browser toolbar.  It also: ◦ Provides a title for.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Working with Objects Creating a Dynamic Web Page.
CITS1231 Web Technologies JavaScript and Document Object Model.
Manipulating the DOM CST 200 – JavaScript 3 –
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.
An Introduction to JavaScript Summarized from Chapter 6 of “Web Programming: Building Internet Applications”, 3 rd Edition.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
CA Professional Web Site Development Class 2: Anatomy of a Web Site and Web Page & Intro to HTML.
DHTML: Working with Objects Creating a Dynamic Web Page.
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.
Web Design (1) Terminology. Coding ‘languages’ (1) HTML - Hypertext Markup Language - describes the content of a web page CSS - Cascading Style Sheets.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 10.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
1 Javascript DOM Peter Atkinson. 2 Objectives Understand the nature and structure of the DOM Add and remove content from the page Access and change element.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
TOPIC II Dynamic HTML Prepared by: Nimcan Cabd Cali.
CO1552 – Web Application Development Further JavaScript: Part 1: The Document Object Model Part 2: Functions and Events.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
DOM (Document Object Model) - Parsing and Reading HTML and XML -
Document Object Model (DOM). Outline  Introduction of DOM  Overview of DOM  DOM Relationships  Standard DOM.
Computer Information System Information System California State University Los Angeles Jongwook Woo CIS 461 Web Development I HTML DOM part I Jongwook.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
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.
1 The tree data structure Outline In this topic, we will cover: –Definition of a tree data structure and its components –Concepts of: Root, internal, and.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Making web pages interactive with JavaScript.
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:
This is a test Webpage Wow, I’m writing my first webpage.
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.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 1 Using HTML to Create Web Pages.
THE DOM.
DHTML.
Web Basics: HTML/CSS/JavaScript What are they?
Applied Online Programming
The Internet and HTML Code
Lecture 8. HTML. Author: Aleksey Semyonov
Introduction to Internet Programming
JavaScript Introduction
Week 11 Web site: XML DOM Week 11 Web site:
The Document Object Model
DHTML Javascript Internet Technology.
HTML A brief introduction HTML.
DHTML Javascript Internet Technology.
Introduction to Programming the WWW I
Document Object Model (DOM): Objects and Collections
Understand basic HTML and CSS terminology, concepts, and basic operations. Objective 3.01.
Introduction to DHTML, the DOM, JS review
HTML MIS 2402 Jeremy Shafer Department of MIS Fox School of Business
HTML5 and CSS3 Illustrated Unit B: Getting Started with HTML
Presentation transcript:

INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE

22 Outline Document Object Model (DOM) Next class CSS

DOM The document’s structure is defined by the W3C Document Object Model (DOM) specification. W3C (World Wide Web Consortium): the main international standards organization for the World Wide Web (WWW or W3). A web browser provides and implements the DOM. When an HTML document is loaded into a browser, it becomes a document object. 3

DOM Is a programming interface for HTML and XML documents. Provides a structured representation of the document Defines a way that the structure can be accessed from programs so that they can change – document structure, – style – content. 4

DOM Provides a representation of the document as a structured group of nodes and objects that have properties and methods. Connects web pages to scripts or programming languages. We use JavaScript to modify the structure and contents of the document. Use Cascading Style Sheets (CSS) to modify the formatting and appearance of the document. 5

DOM When JavaScript is hosted in a browser, the browser provides the window host object to JavaScript. The window displays a document, but it also has some notion of history (back/forward), location (the address bar), navigator (e.g. the browser version etc.) and so on. 6

DOM The window’s document property is a reference to the HTML document in the browser tab/window. The document property is the root, or start point, of the DOM API. Use document keyword, or the fully-qualified window.document identifier. 7

Organization of a Document Tree structure 8 From: Peter McIntyre

Hello, world! Welcome Hello, world! This is my home page. Hello, world! Welcome Hello, world! This is my home page

10 html head body title div h3 p p Hello, world! Welcome Hello, world! This is my home page

Node Building Block/ Foundation All endpoints in the document object model are nodes. Node types: – Element – an HTML element, e.g. p, div, img – Text – text content in an element – Attribute – for an element; e.g. the src attribute for the img element 11

Node’s id attribute Get a reference to a specific element in the document object. E.g., to change its text/content, or append new content to the element. Get the element by ID: document.getElementById() 12

13 Hello, world! Welcome Hello, world! This is my home page. ScratchPad: var desired_element = document.getElementById("main"); var new_element = document.createElement("p"); var new_text_content = document.createTextNode("Have fun!"); new_element.appendChild(new_text_content); desired_element.appendChild(new_element);

14 Hello, world! function addTextNode() { var desired_element = document.getElementById("main"); var new_element = document.createElement("p"); var new_text_content = document.createTextNode("Have fun!"); new_element.appendChild(new_text_content); desired_element.appendChild(new_element); } Welcome Hello, world! This is my home page. Have Fun

15 html head body title div h3 p p Hello, world! Welcome Hello, world!This is my home page p Have fun!

Node All content in an HTML document becomes a node in the DOM. All nodes (except for the root) have a parent node. A node can have zero or more child nodes (children). For example, several p elements inside a div container. A node can also have zero or more siblings. E.g., when several elements are in a container – they don’t need to have the same element name – a specific element node can have a next sibling, and previous sibling. 16

Next Class CSS 17

Thank you!