Working with Objects Creating a Dynamic Web Page.

Slides:



Advertisements
Similar presentations
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.
Advertisements

JavaScript Objects - DOM CST 200 JavaScript. Objectives Introduce JavaScript objects Introduce Document Object Model Introduce window object Introduce.
The Web Warrior Guide to Web Design Technologies
COMPSCI 345 / SOFTENG 350 TUTORIAL WEEK 8 | SAM KAVANAGH.
Chapter Concepts Review Markup Languages
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
ISP 523: Fundamentals of Information Technology Instructor: Stephen Lackey November 2, 2005.
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,
1st Project Introduction to HTML.
Chapter ONE Introduction to HTML.
INTRODUCTION TO CLIENT-SIDE WEB PROGRAMMING ACM 511 ACM 262 Course Notes.
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.
4.1 JavaScript Introduction
HTML Forms and Scripts. Session overview What are forms? Static vs dynamic Client-side scripts –JavaScript.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
10 Adding Interactivity to a Web Site Section 10.1 Define scripting Summarize interactivity design guidelines Identify scripting languages Compare common.
Lesson 19. JavaScript errors Since JavaScript is an interpreted language, syntax errors will usually cause the script to fail. Both browsers will provide.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Creating an Animated 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.
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
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.
XP Tutorial 12 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Special Effects Creating Rollovers, Menus, Filters, and Transitions.
DHTML - Introduction Chapter Introduction to DHTML, the DOM, JS review.
 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.
XP Tutorial 6 New Perspectives on JavaScript, Comprehensive1 Working with Windows and Frames Enhancing a Web Site with Interactive Windows.
Chapter 7: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
Web Design (1) Terminology. Coding ‘languages’ (1) HTML - Hypertext Markup Language - describes the content of a web page CSS - Cascading Style Sheets.
XP Tutorial 16 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
Session: 1. © Aptech Ltd. 2Introduction to the Web / Session 1  Explain the evolution of HTML  Explain the page structure used by HTML  List the drawbacks.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
DHTML. What is it? Dynamic HTML. Not a standard unlike HTML or Java It is a term applied by both Netscape and Microsoft to a collection of technologies.
TOPIC II Dynamic HTML Prepared by: Nimcan Cabd Cali.
Web Terminology Intro to Web. North Lake College 2 by Sean Griffin HTML vs. XHTML HTML: Hypertext Markup Language XHTML: eXtensible Hypertext Markup Language.
JavaScript Overview Developer Essentials How to Code Language Constructs The DOM concept- API, (use W3C model) Objects –properties Methods Events Applications;
INTRODUCTION JavaScript can make websites more interactive, interesting, and user-friendly.
XP Tutorial 5 New Perspectives on JavaScript, Comprehensive1 Working with Special Effects Creating Rollovers, Menus, Filters, and Transitions.
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.
Project 7: Exploring DHTML Essentials for Design JavaScript Level Two Michael Brooks.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
The Web Wizard’s Guide To DHTML and CSS Chapter 2 A Review of CSS2 and JavaScript.
XP Tutorial 10 New Perspectives on JavaScript, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
Chapter 13: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
DHTML.
Project 1 Introduction to HTML.
Javascript and Dynamic Web Pages: Client Side Processing
Programming Web Pages with JavaScript
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
JavaScript Event Handling.
Project 1 Introduction to HTML.
Section 17.1 Section 17.2 Add an audio file using HTML
Introduction to Programming the WWW I
JavaScript Introduction
DHTML Javascript Internet Technology.
Chapter 13 - Dynamic HTML: Object Model and Collections
DHTML Javascript Internet Technology.
Introduction to Programming the WWW I
Introduction to DHTML, the DOM, JS review
Presentation transcript:

Working with Objects Creating a Dynamic Web Page

Introduction Developers began to look for ways to create dynamic pages New approach, in which the HTML code itself supported dynamic elements Known collectively as dynamic HTML (DHTML), or now incorporated in HTML5

Introduction cont. Interaction of three aspects –A page’s HTML/XHTML code –A style sheet that defines the styles used in the page –A script to control the behavior of elements on the page

Introduction cont. Some uses –Animated text –Pop-up menus –Rollovers –Web pages that retrieve their content from external data sources –Elements that can be dragged and dropped

Understanding JavaScript Objects JavaScript is an object-based language An object is any item associated with a Web page or Web browser Each object has –Properties –Methods

Exploring the Document Object Model The organized structure of objects and events is called the document object model, or DOM Every object related to documents or to browsers should be part of the document object model In practice, browsers differ in the objects that their document object models support

Exploring the Document Object Model Development of a Common DOM –Basic model, or DOM Level 0 –Supported browser window, Web document, and the browser itself –Development followed two paths: one adopted by Netscape and the other adopted by Internet Explorer

Exploring the Document Object Model Development of a Common DOM –World Wide Web Consortium (W3C) stepped in to develop specifications for a common document object model DOM Level 1 DOM Level 2 DOM Level 3 –Within each DOM, particular features may not be supported by every browser

Exploring the Document Object Model The document tree

Referencing Objects A DOM can be used by any scripting language including JavaScript and Java

Referencing Objects Object Names –Each object is identified by an object name

Referencing Objects Object Names –General form is object1.object2.object3… –To reference the history you would use the form window.history –For the body, you would use document.body

Referencing Objects Using W3C DOMs –Can reference objects using their id or name values, document.getElementsbyId(“id”) document.getElementsbyTagName(“tag”)

Working with Object Properties The syntax for setting the value of an object content,property, and attribute is –document.getElementsByID(“id”).innerHTML= “value” –document.getElementsByID(“id”).style.property= “value” –document.getElementById(id).attribute= “new value” Example –document.getElementsByID(“p”).innerHTML= “new text” –document.getElementsByID(“p”).color= “blue” –document.getElementById(“image”).src= “test.jpg”

Working with the style Object The syntax for applying a style is object.style.attribute = value more examples:

Creating a Cross-Browser Web Site You can create this kind of code, known as cross-browser code, using two different approaches: browser detection or object detection

Creating a Cross-Browser Web Site Using Browser Detection –Using browser detection, your code determines which browser (and browser version) a user is running navigator.appName –Most browser detection scripts – commonly known as browser sniffers – use this property to extract information about the version number navigator.uerAgent

Creating a Cross-Browser Web Site Using Object Detection –With object detection, you determine which document object model a browser supports var W3CDOM = document.getElementByID ? true:false;

Creating a Cross-Browser Web Site Employing Cross-Browser Strategies –One strategy, called page branching, creates separate pages for each browser along with an initial page –A script determines the capabilities of the user’s browser and automatically loads the appropriate page

Creating a Cross-Browser Web Site Employing Cross-Browser Strategies