 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.

Slides:



Advertisements
Similar presentations
Session 10 Dynamic HTML: Cascading Style Sheets™ (CSS), Object Model and Collections Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
Advertisements

Pemrograman Teknologi Internet W09: DOM & DHTML. 2 Objectives DOM: DOM: DOM Nodes & Trees DOM Nodes & Trees Traversing & Modifying DOM Trees Traversing.
Ch. 6 Web Page Design – Absolute Positioning, Image Maps, and Navigation Bars Mr. Ursone.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Tutorial 4 Creating Special Effects with CSS
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic DHTML.
Tutorial 13 Working with Objects and Styles. XP Objectives Learn about objects and the document object model Reference documents objects by ID, name,
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
DHTML - Introduction Introduction to DHTML, the DOM, JS review.
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.
INTRODUCTION TO DHTML. TOPICS TO BE DISCUSSED……….  Introduction Introduction  UsesUses  ComponentsComponents  Difference between HTML and DHTMLDifference.
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
Tutorial 4 Creating Special Effects with CSS
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Tutorial 6 By Sam INE 1020 Introduction to Internet Engineering 1 DHTML & CSS Tutorial 6.
Lecture 11 – DOM Scripting SFDV3011 – Advanced Web Development Reference: 1.
1 JavaScript: Objects and Object Models October 25, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel,
DHTML Positioning and Layout. What is DHTML? HTML and xHTML CSS JavaScript or VBScript.
Creating an Animated Web Page
Working with Objects Creating a Dynamic Web Page.
CITS1231 Web Technologies JavaScript and Document Object Model.
XP Tutorial 4 New Perspectives on JavaScript, Comprehensive1 Working with Objects Creating an Animated Web Page.
 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.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 7.
DHTML - Introduction Chapter Introduction to DHTML, the DOM, JS review.
Interactive Client-Side Technologies MMIS 656 Web Design Technologies Acknowledgements: Estrella, S. (2003). The Web Wizard’s Guide to DHTML and CSS.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
 2001 Deitel & Associates, Inc. All rights reserved. 1 Chapter 20 – Dynamic HTML: Object Model and Collections Outline 20.1Introduction 20.2Object Referencing.
DHTML: Working with Objects Creating a Dynamic Web Page.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 7.
Chapter 8 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 8 Sebesta: Programming the World Wide Web.
Chapter 7: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
CSS1 Dynamic HTML Objects, Collections & Events. CSS2 Introduction Dynamic HTML treats HTML elements as objects. Element’s parameters can be treated as.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Positioning and Printing Creating Special Effects with CSS.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
Introducing DHTML. Goals Understand the concept of DHTML as a tool for creating dynamic content Understand how to use DOM properties to make changes in.
Document Object Model (DOM). Outline  Introduction of DOM  Overview of DOM  DOM Relationships  Standard DOM.
Lesson 30: JavaScript and DHTML Fundamentals. Objectives Define and contrast client-side and server-side technologies used to create dynamic content for.
The Web Wizard’s Guide To DHTML and CSS Chapter 2 A Review of CSS2 and JavaScript.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 6.
Chapter 6 Murach's JavaScript and jQuery, C6© 2012, Mike Murach & Associates, Inc.Slide 1.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 15 – Dynamic HTML: Object Model and Collections Outline 15.1Introduction 15.2Object Referencing.
Project 7: Exploring DHTML Essentials for Design JavaScript Level Two Michael Brooks.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
The Web Wizard’s Guide To DHTML and CSS Chapter 2 A Review of CSS2 and JavaScript.
Chapter 13: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
Working with Cascading Style Sheets
DHTML.
Using DHTML to Enhance Web Pages
Chapter 13 - Dynamic HTML: Object Model and Collections
DynamicHTML Cascading Style Sheet Internet Technology.
Chapter 13 - Dynamic HTML: Object Model and Collections
Tutorial 4 Creating Special Effects with CSS
Introduction to DHTML, the DOM, JS review
COP 3813 Intro to Internet Computing
Presentation transcript:

 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing 13.3 Collections all and children 13.4 Dynamic Styles 13.5 Dynamic Positioning 13.6 Using the frames Collection 13.7 navigator Object 13.8 Summary of the DHTML Object Model

 2004 Prentice Hall, Inc. All rights reserved. Objectives –To use the Dynamic HTML Object Model and scripting to create dynamic Web pages. –To understand the Dynamic HTML object hierarchy. –To use the all and children collections to enumerate all of the XHTML elements of a Web page. –To use dynamic styles and dynamic positioning. –To use the frames collection to access objects in a separate frame on your Web page. –To use the navigator object to determine which browser is being used to access your page.

 2004 Prentice Hall, Inc. All rights reserved. Goals Understand the concept of DHTML as a tool for creating dynamic content Understand how to use DOM properties to make changes in the appearance of HTML objects Understand how to create and use objects not explicitly created by HTML

 2004 Prentice Hall, Inc. All rights reserved. DHTML DHTML is not HTML DHTML is not a programming language DHTML is a programming model for designing Web pages that incorporates: –JavaScript –DOM –CSS –HTML

 2004 Prentice Hall, Inc. All rights reserved. DHTML vs. HTML HTML Static Limited I/O Little Interactivity DHTML Dynamic Changes elements with changes in the environment Relies heavily on interactivity

 2004 Prentice Hall, Inc. All rights reserved. DHTML Rules of Thumb For use with 4.x versions of the browsers Some DHTML scripts can be browser-dependent: –Some versions of image swapping –Hover for anchor tags

 2004 Prentice Hall, Inc. All rights reserved. DHTML A combination of technologies used to create animated documents Not a W3C standard! –Originally, a marketing term used by Netscape and Microsoft Using scripts, we manipulate HTML content and style properties in reaction to events

 2004 Prentice Hall, Inc. All rights reserved. Dynamic HTML XHTML content CSS style rules appearanceScriptingLanguage manipulate

 2004 Prentice Hall, Inc. All rights reserved. Introduction Dynamic HTML Object Model –Allows Web authors to control the presentation of their pages –Gives them access to all the elements on their pages Web page –Elements, forms, frames, tables –Represented in an object hierarchy Scripting –Retrieve and modify properties and attributes

 2004 Prentice Hall, Inc. All rights reserved. Object Referencing The simplest way to reference an element is by using the element’s id attribute. The element is represented as an object –XHTML attributes become properties that can be manipulated by scripting

 2004 Prentice Hall, Inc. All rights reserved. HTML DOM From W3C: “A platform- and language-neutral interface that allows programs and scripts to dynamically access and update the content and structure of HTML and XHTML documents.”

 2004 Prentice Hall, Inc. All rights reserved. DOM and JavaScript Combined with JavaScript, every element in the HTML document is represented by an object Elements can be manipulated using the properties and methods of the corresponding objects Changes in the element properties are immediately reflected by the browser

 2004 Prentice Hall, Inc. All rights reserved. Accessing HTML Elements All HTML elements (objects) are accessed through the document object document itself is automatically created Several ways to access a specific element –paths in the DOM tree –retrieval by tag –retrieval by ID

 2004 Prentice Hall, Inc. All rights reserved. HTML DOM Tree

 2004 Prentice Hall, Inc. All rights reserved. Accessing Elements by Paths function execute() { var img = document.images[0]; img.src="lighton.gif" var inx = document.forms[0].elements[0]; inx.value="xx" var iny = document.forms["form1"].elements["y"]; iny.value="yy" } body head

 2004 Prentice Hall, Inc. All rights reserved. Accessing Elements by Tags This example is lovely. But this one is even more! function execute() { var spans = document.getElementsByTagName("span"); spans[0].style.color="red"; spans[1].style.color="blue"; spans[1].style.fontVariant="small-caps"; } body head

 2004 Prentice Hall, Inc. All rights reserved. Accessing Elements by ID This text can be hidden! function execute() { var theDiv = document.getElementById("div1"); if (theDiv.style.visibility=="hidden") {theDiv.style.visibility="visible" } else {theDiv.style.visibility="hidden" } } head This technique is more stable w.r.t. document changes (why?) body

 2004 Prentice Hall, Inc. All rights reserved. Element Properties Elements of different types have different sets of properties and methods Most elements have the style member style is an object that represents the style- sheet rules applied over the element

 2004 Prentice Hall, Inc. All rights reserved. Outline reference.html (1 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline reference.html (2 of 2)

 2004 Prentice Hall, Inc. All rights reserved Collections all and children Collections –Arrays of related objects on a page –all all the XHTML elements in a document –children Specific element contains that element’s child elements

 2004 Prentice Hall, Inc. All rights reserved. Outline all.html (1 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline all.html (2 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline children.html (1 of 3)

 2004 Prentice Hall, Inc. All rights reserved. Outline children.html (2 of 3)

 2004 Prentice Hall, Inc. All rights reserved. Outline children.html (3 of 3)

 2004 Prentice Hall, Inc. All rights reserved.

13.4 Dynamic Styles Element’s style can be changed dynamically Dynamic HTML Object Model also allows you to change the class attribute

 2004 Prentice Hall, Inc. All rights reserved. Outline dynamicstyle.html (1 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline dynamicstyle.html (2 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline dynamicstyle2.html (1 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline dynamicstyle2.html (2 of 2)

 2004 Prentice Hall, Inc. All rights reserved.

13.5 Dynamic Positioning Enables XHTML elements can be positioned with scripting –Declare an element’s CSS position property to be either absolute or relative –Move the element by manipulating any of the top, left, right or bottom CSS properties

 2004 Prentice Hall, Inc. All rights reserved. CSS-P Attributes Left – the elements left position Top - the elements top position Visibility – specifies whether an element should be visible or hidden Z-index – the elements stack order Clip – element clipping Overflow – how overflow contents are handled

 2004 Prentice Hall, Inc. All rights reserved. Position This property allows you to control the positioning of an element Position :relative –Position an element relative to its current position div{ Position :relative Left:10; } Position div element 10 pixels to right

 2004 Prentice Hall, Inc. All rights reserved. Position Position :absolute –Position an element from the margin of the window div{ Position : absolute Left:10; } Position div element 10 pixels to right from the left margin of its containing block

 2004 Prentice Hall, Inc. All rights reserved. Visibility Determines element is visible or not Visibility :visible H1{ visibility:visible;} make visible Visibility:hidden H1: { Visibility:hidden;} make invisible

 2004 Prentice Hall, Inc. All rights reserved. Z-index To place an element behind another element Default it is 0.The higher number has higher priority. Exp H1{ z-index:1; } H2{ Z-index:2; }

 2004 Prentice Hall, Inc. All rights reserved. Outline dynamicposition.html (1 of 3)

 2004 Prentice Hall, Inc. All rights reserved. Outline dynamicposition.html (2 of 3)

 2004 Prentice Hall, Inc. All rights reserved. Outline dynamicposition.html (3 of 3)

 2004 Prentice Hall, Inc. All rights reserved.

13.6 Using the frames Collection Referencing elements and objects in different frames by using the frames collection

 2004 Prentice Hall, Inc. All rights reserved. Outline index.html (1 of 1)

 2004 Prentice Hall, Inc. All rights reserved. Outline top.html (1 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline top.html (2 of 2)

 2004 Prentice Hall, Inc. All rights reserved.

13.7 navigator Object Netscape, Mozilla, Microsoft’s Internet Explorer –Others as well Contains information about the Web browser Allows Web authors to determine what browser the user is using

 2004 Prentice Hall, Inc. All rights reserved. Outline navigator.html (1 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline navigator.html (2 of 2)

 2004 Prentice Hall, Inc. All rights reserved Summary of the DHTML Object Model applets all anchors embeds forms filters images links plugins styleSheets scripts frames plugins collection body screen document history navigator location event document object window Key Fig DHTML Object Model.

 2004 Prentice Hall, Inc. All rights reserved Summary of the DHTML Object Model

 2004 Prentice Hall, Inc. All rights reserved Summary of the DHTML Object Model

 2004 Prentice Hall, Inc. All rights reserved Summary of the DHTML Object Model