Chapter 7: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.

Slides:



Advertisements
Similar presentations
1 Introduction to Web Application Implement JavaScript in HTML.
Advertisements

The Document Object Model (DOM) 1 JavaScript is an object-based language—that is, it’s based on manipulating objects by changing each object’s properties.
Pemrograman Teknologi Internet W09: DOM & DHTML. 2 Objectives DOM: DOM: DOM Nodes & Trees DOM Nodes & Trees Traversing & Modifying DOM Trees Traversing.
The Web Warrior Guide to Web Design Technologies
JavaScript (Part 2) CS 183 4/13/2010. JavaScript (Part 2) Will cover: ◦ For.. In ◦ Events ◦ Try.. Catch, Throw ◦ Objects.
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
Page 1 of 39 Javascript Chapters 13, 14 Vadim Parizher Computer Science Department California State University, Northridge Fall 2003 Slides from text Book.
Computer Science 103 Chapter 4 Advanced JavaScript.
JavaScript 101 Lesson 5: Introduction to Events. Lesson Topics Event driven programming Events and event handlers The onClick event handler for hyperlinks.
JavaScript, Third Edition
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.
Chapter 7: Dynamic HTML and Animation JavaScript - Introductory.
Tutorial 13 Working with Objects and Styles. XP Objectives Learn about objects and the document object model Reference documents objects by ID, name,
DHTML - Introduction Introduction to DHTML, the DOM, JS review.
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.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
Chapter 19: Adding JavaScript
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
1 JavaScript: Event Model November 1, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel, and Goldberg.
DOM and JavaScript Aryo Pinandito.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
1 JavaScript: Objects and Object Models October 25, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel,
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
Creating an Animated Web Page
Working with Objects Creating a Dynamic Web Page.
CITS1231 Web Technologies JavaScript and Document Object Model.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
DHTML - Introduction Chapter Introduction to DHTML, the DOM, JS review.
 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.
JavaScript - A Web Script Language Fred Durao
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
Introduction to the Document Object Model DOM *Understand document structure manipulation *Dynamic effects in web pages *Programming, scripting, web content.
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
JavaScript, Fourth Edition Chapter 4 Manipulating the Browser Object Model.
CSS1 Dynamic HTML Objects, Collections & Events. CSS2 Introduction Dynamic HTML treats HTML elements as objects. Element’s parameters can be treated as.
Introduction to DHTML. What is DHTML? Dynamic HTML Just as Access is Dynamic Database environment Can have controls that respond to events Can have centralized.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
Rich Internet Applications 3. Client JavaScript. Document Object Model (DOM) The DOM, is an interface that allows scripts or programs to access and manipulate.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
Lesson 30: JavaScript and DHTML Fundamentals. Objectives Define and contrast client-side and server-side technologies used to create dynamic content for.
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
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.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Chapter 13: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Using DHTML to Enhance Web Pages
Chapter 14: DHTML: Event Model
Web Development & Design Foundations with HTML5 7th Edition
JAVASCRIPTS AND HTML DOCUMENTS
The Web Wizard’s Guide To DHTML and CSS
DHTML Javascript Internet Technology.
Chapter 13 - Dynamic HTML: Object Model and Collections
Chapter 13 - Dynamic HTML: Object Model and Collections
DHTML Javascript Internet Technology.
Web Design and Development
Introduction to DHTML, the DOM, JS review
COP 3813 Intro to Internet Computing
Presentation transcript:

Chapter 7: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I

2 Object Referencing The DHTML Object Model gives web authors access to all elements on their web page through ________. Elements can be referenced through the __ attribute. Example in HTML: Welcome! in JavaScript: pText.innerText = “Thanks for coming.”; The object pText has the property __________. When the JS is executed, the text in the web page changes, giving the web page _________ content. See reference.html.reference.html

3 Collections Collections are ________ of related objects on a page. The _____ collection is an array of all XHTML elements in a document in the order of appearance. This allows a reference even without an __ attribute. document.all[0].tagname would return “HTML” if the tag _______ is first on the page. document.all[0].children[0].tagname would return “HEAD” if the tag is first after _______. See all.html and children.html.all.htmlchildren.html

4 Dynamic Styles An element’s ______ can be changed dynamically. Changing background color (see p. 436): var inputColor = prompt(“Enter a color name for the page background”, “”); document.body.style.backgroundColor = inputColor; Changing ______ attributes of elements (see p. 437) The CSS:.bigText {font-size: 3em; font-weight: bold} The JavaScript: var inputClass = prompt(“Enter a class name”, “”); pText.className = inputClass; The HTML: Welcome!

5 Dynamic Positioning You can position elements on a web page with scripting using the CSS __________ property. Many dynamic events are controlled by timing. Set a timer for repeated function execution: var timer = window.setInterval(“aFunction()”, 1000); The function aFunction() is called every 1000 ms Set a timer for a single function execution: var timer = window.setTimeout(“aFunction()”, 1000); The function aFunction() is called once after 1000 ms Stop a timer: window.clearInterval(timer); window.clearTimeout(timer); See example dynamicposition.html.dynamicposition.html

6 The frames Collection A web page can access another page in a frame using the frame’s name: parent.frames(“ ”) See index.html and top.html.index.htmltop.html

7 The navigator Object Different web browsers operate differently Microsoft IE vs. Mozilla Firefox Different versions of Microsoft IE The JavaScript __________ object can detect the browser and version, then redirect users to the appropriate web page. navigator.appName returns either “Microsoft Internet Explorer”, “Netscape”, “Mozilla”, etc. navigator.appVersion.substring(1,0) returns the first character in the browser _______ (4, 5, 6, etc.). document.location = “ ”; loads the desired page (see navigator.html ). navigator.html

8 Summary See and us/library/ms aspx for additional resources. us/library/ms aspx

9 More Examples Listing 7-1 in Moseley ( setInterval ): … var e = document.getElementById( “urgent” ); setInterval( “e.style.backgroundColor = colors[ nextColor++ % colors.length ];”, 500); Listing 7-2 in Moseley (images):

10 The Image Object Creating and sourcing an Image object: anImage = new Image(); anImage.src = “suki.jpg”; Using an array of Image objects: var imagesArray = new Array(6); for( var i = 0; i < 6; i++ ){ imagesArray[ i ] = new Image(); imagesArray[ i ].src = “anim” + i + “.jpg”; } see listing on Moseley p. 152 using setTimeout and clearTimeout Listing 7-4 gives a complex example of dynamic positioning.

11 Events and Buttons Events (such as onclick ) trigger event ________ Event handlers catch event objects and execute code Example events: onblur (leave an object) onclick (click an object) onmouseover (cursor moves over an object) onsubmit (submit a form) Using events: Click for the time!