ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming DOM.

Slides:



Advertisements
Similar presentations
JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
Advertisements

HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Lesson 12- Unit L Programming Web Pages with JavaScript.
Chapter 6 © 2012 by Addison Wesley Longman, Inc Introduction Def: A dynamic HTML document is one whose tag attributes, tag contents, or element.
Dynamic HTML Netscape Navigator (NN) 6.0 & Internet Explorer (IE) 5.0.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Macromedia Dreamweaver 4 Advanced Level Course. Add Rollovers Rollovers or mouseovers are possibly the most popular effects used in designing Web pages.
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
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.
© Cheltenham Computer Training 2001 Macromedia Dreamweaver 4 - Slide No 1 Macromedia Dreamweaver 4 Advanced Level Course.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Lesson 19. JavaScript errors Since JavaScript is an interpreted language, syntax errors will usually cause the script to fail. Both browsers will provide.
CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Advanced DHTML.
DHTML Positioning and Layout. What is DHTML? HTML and xHTML CSS JavaScript or VBScript.
Dynamic Web Authoring Week3 – Javascript Basic COM311H Zheng, School of C&M, UUJ1.
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
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.
Manipulating the DOM CST 200 – JavaScript 3 –
Advanced DHTML.
JavaScript – The DOM JavaScript is object based The browser is object based – We can access the browser's objects in the same way we did JavaScript's Two.
JavaScript, Fourth Edition
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
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.
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.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
ECA 225 Applied Interactive Programming ECA 225 Applied Online Programming images.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 10.
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
CSS1 Dynamic HTML Objects, Collections & Events. CSS2 Introduction Dynamic HTML treats HTML elements as objects. Element’s parameters can be treated as.
JavaScript. JavaScript is the programming language of HTML and the Web. Easy to learn One of the 3 languages of all developers MUST learn: 1. HTML to.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming DHTML Example.
JavaScript Introduction. Slide 2 Lecture Overview JavaScript background The purpose of JavaScript A first JavaScript example Introduction to getElementById.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Web Technologies Lecture 8 JQuery. “A fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax.
Chapter 6 © 2014 by Pearson Education Introduction Def: A dynamic HTML document is one whose tag attributes, tag contents, or element style properties.
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.
Lesson 30: JavaScript and DHTML Fundamentals. Objectives Define and contrast client-side and server-side technologies used to create dynamic content for.
Dr. Ahmet Cengizhan Dirican BIL 374 Internet Technologies 6. Dynamic Documents With JavaScript.
The Web Wizard’s Guide To DHTML and CSS Chapter 2 A Review of CSS2 and JavaScript.
Project 7: Exploring DHTML Essentials for Design JavaScript Level Two Michael Brooks.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
1 Objects In JavaScript. 2 Types of Object in JavaScript Built-in objects User Defined Objects Browser Object Document Object Model.
JAVASCRIPT A quick review. True False ■The DOM is a standardized way of referring to parts of a Web page. ■TRUE ■In the DOM, attributes have their own.
The Web Wizard’s Guide To DHTML and CSS Chapter 2 A Review of CSS2 and JavaScript.
DHTML.
Programming Web Pages with JavaScript
Applied Online Programming
Document Object Model (DOM): Objects and Collections
JavaScript Introduction
DHTML Javascript Internet Technology.
DHTML Javascript Internet Technology.
Introduction to Programming the WWW I
Working with Dynamic Content and Styles
Introduction to DHTML, the DOM, JS review
JavaScript CS 4640 Programming Languages for Web Applications
Tutorial 10: Programming with javascript
JavaScript CS 4640 Programming Languages for Web Applications
Presentation transcript:

ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming DOM

ECA 225 Applied Interactive Programming2 DHTML  HTML  CSS  JavaScript  DOM  dynamically alter the style properties of a web page element by using JavaScript

ECA 225 Applied Interactive Programming3 Browser incompatibility  NN v. 4  “layers” to control positioning, stacking order, visibility  MSIE  Active X  visual filters

ECA 225 Applied Interactive Programming4 DHTML  advantages  supported in all major browsers since NN4 and IE4  standards are becoming consistent and open  can change content on the fly without having to return to the server  small file sizes  no plug-ins are required  easy to learn  since it’s client side, it’ relatively fast  disadvantages  incompatibilities among browsers and OS  picky syntax

ECA 225 Applied Interactive Programming5 Macromedia Flash  advantages  consistent across browsers and OS  ubiquitous – according to Macromedia, 95% of visitors have some form of plug-in installed  cool  small file sizes if created properly  disadvantages  hard to learn and create  expensive  fear of plug-ins  if created haphazardly, file sizes can be large

ECA 225 Applied Interactive Programming6 DOM  Document Object Model  structure and syntax to access any element / object  define an object by giving it a name or id  XHTML standards are phasing out “name” in favor of “id”  some older browsers do not recognize “id” for images  developers can use both “name” and “id”

ECA 225 Applied Interactive Programming7 DOM cont …  to access elements / objects, use dot notation  “node” – the address, using dot notation, of the element document.myForm.first_name.value;

ECA 225 Applied Interactive Programming8 DOM cont …  many HTML elements / objects are stored in a JavaScript array  3 images named image1, image2, image3 or document.images[ “image1” ]; document.images[ “image2” ]; document.images[ “image3” ]; document.images[ 0 ]; document.images[ 1 ]; document.images[ 2 ];

ECA 225 Applied Interactive Programming9 DOM cont …  the same is true for elements in a form or document.myForm.elements[ 0 ] //refers to first_name document.myForm.elements[ 1 ] //refers to last_name document.myForm.elements[ “first_name” ] //refers to first_name document.myForm.elements[ “last_name” ] //refers to last_name

ECA 225 Applied Interactive Programming10 DOM cont …  browser support for a consistent DOM was lacking  the W3C created a standardized DOM  NN6 & NN7  IE5 & IE6  Safari  Opera

ECA 225 Applied Interactive Programming11 DOM – older browsers  NN4  first browser to support DHTML  created “layers” property  NN4 DOM not supported by subsequent releases of Netscape Navigator  IE4  closer to the recommended DOM  created “all” property  no longer supported by latest IE browsers

ECA 225 Applied Interactive Programming12 DOM – older browsers cont … NN4 IE This is myLayer1. document.layers.myLayer1 ~~~ or ~~~ document.layers[ “myLayer1” ] document.all.myLayer1 ~~~ or ~~~ document.all[ “myLayer1” ]

ECA 225 Applied Interactive Programming13 DOM – W3C standard  access any HTML element in the browser  getElementById( ) method  pass the id of the element to be accessed  can be exact id, or variable document.getElementById( “myExample1” ) ; var theArg = “myExample1” ; document.getElementById( theArg ) ;

ECA 225 Applied Interactive Programming14 DOM – browser detection  check for browser support of the DOM if( document.getElementById ) { // code for later browsers } else if( document.all ) { //code for IE4 } else if( document.layers ){ // code for NN4 }

ECA 225 Applied Interactive Programming15 DOM & CSS  accessing style properties  access element, then style property  CSS properties are normally hyphenated  JavaScript does not allow use of hyphens  drop the hyphen, capitalize the next letter var theArg = “myExample1” ; var obj = document.getElementById( theArg ) ; alert( obj.style.zIndex ); zIndex

ECA 225 Applied Interactive Programming16 DOM & CSS cont …  browsers return values with “px” appended for properties such as “top” or “left”  use parseInt( ) to drop “px” var theArg = “myExample1” ; var obj = document.getElementById( theArg ) ; var myTop = parseInt(obj.style.top ) ; alert( myTop ); 200px

ECA 225 Applied Interactive Programming17 DOM & CSS cont …  XHTML standards require that all style values be assigned as strings, not numbers  to change numeric value to string  concatenate  quotes document.getElementById("myLayer1").style.top = 50 + “px”; document.getElementById("myLayer1").style.top = "50";