Tutorial 16 Working with Dynamic Content and Styles.

Slides:



Advertisements
Similar presentations
Tutorial 6 Creating a Web Form
Advertisements

HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
The Web Warrior Guide to Web Design Technologies
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Tutorial 6 Working with Web Forms
Tutorial 15 Working with the Event Model. XP Objectives Compare the IE and W3C event models Study how events propagate under both event models Write a.
Tutorial 10 Programming with JavaScript
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Tutorial 4 Creating Special Effects with CSS
Tutorial 11 Working with Operators and Expressions
Tutorial 14 Working with Forms and Regular Expressions.
Tutorial 13 Working with Objects and Styles. XP Objectives Learn about objects and the document object model Reference documents objects by ID, name,
XP Tutorial 8 New Perspectives on JavaScript, Comprehensive1 Working with the Event Model Creating a Drag-and-Drop Shopping Cart.
Developing a Basic Web Page with HTML
INTRODUCTION TO CLIENT-SIDE WEB PROGRAMMING ACM 511 ACM 262 Course Notes.
WORKING WITH NAMESPACES
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
4.1 JavaScript Introduction
Tutorial 5 Working with Web Tables. XP Objectives Explore the structure of a Web table Create headings and cells in a table Create cells that span multiple.
Tutorial 14 Working with Forms and Regular Expressions.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
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.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
WORKING WITH XSLT AND XPATH
XP New Perspectives on XML, 2 nd Edition Tutorial 10 1 WORKING WITH THE DOCUMENT OBJECT MODEL TUTORIAL 10.
Tutorial 4 Creating Special Effects with CSS
Lecture 11 – DOM Scripting SFDV3011 – Advanced Web Development Reference: 1.
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.
JavaScript, Fourth Edition
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.
1 Dr Alexiei Dingli XML Technologies XML Advanced.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Copyright 2007, Information Builders. Slide 1 Understanding Basic HTML Amanda Regan Technical Director June, 2008.
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.
USING XML AS A DATA SOURCE. Data binding is a process by which information in a data source is stored as an object in computer memory. In this presentation,
XP 1 New Perspectives on XML Binding XML Data with Internet Explorer.
XP 1 Creating an XML Document Developing an XML Document for the Jazz Warehouse XML Tutorial.
XP New Perspectives on XML, 2nd Edition Tutorial 2 1 TUTORIAL 2 WORKING WITH NAMESPACES.
XP Tutorial 16 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
© 2011 Delmar, Cengage Learning Chapter 3 Working with Text and Cascading Style Sheets.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
JavaScript, Fourth Edition
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Review of the DOM Node properties and methods Some ways of accessing nodes Appending, copying and removing nodes Event handling – Inline – Scripting –
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
XP Review 1 New Perspectives on JavaScript, Comprehensive1 Introducing HTML and XHTML Creating Web Pages with HTML.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
XML DOM Week 11 Web site:
Tutorial 6 Creating a Web Form
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Tutorial 5 Working with Web Tables. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Learn and Apply the structure of.
Introduction to JavaScript DOM Instructor: Sergey Goldman.
XP Tutorial 10 New Perspectives on JavaScript, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
Using DHTML to Enhance Web Pages
Working with the Event Model
Working with Dynamic Content and Styles
Document Object Model (DOM): Objects and Collections
Presentation transcript:

Tutorial 16 Working with Dynamic Content and Styles

XP Objectives Learn how to create dynamic content under the IE DOM Understand the methods and properties of nodes and the node tree Learn to create element and text nodes Understand how to attach nodes to a Web page document New Perspectives on HTML, XHTML, and Dynamic HTML, 4e2

XP Objectives Apply node properties and styles to create dynamic content Work with the properties and methods of attribute nodes Work with element attributes New Perspectives on HTML, XHTML, and Dynamic HTML, 4e3

XP Objectives Hide and redisplay Web page objects Understand how to create recursive functions to navigate a node tree Learn to work with the properties and methods of style sheet objects New Perspectives on HTML, XHTML, and Dynamic HTML, 4e4

XP Introducing Dynamic Content New Perspectives on HTML, XHTML, and Dynamic HTML, 4e5

XP Introducing Dynamic Content Inserting HTML Content into an Element – Generating a table of contents involves working with dynamic content, which is content determined by the operation of a script running within the browser – One property that can be used to write content in an element is the innerHTML property object.innerHTML = content New Perspectives on HTML, XHTML, and Dynamic HTML, 4e6

XP Introducing Dynamic Content Inserting HTML Content into an Element New Perspectives on HTML, XHTML, and Dynamic HTML, 4e7

XP Introducing Dynamic Content Dynamic Content in Internet Explorer – The innerHTML property is not part of the official specifications for the W3C document object model – However, since it has proven valuable and easy to use, it is supported by all browsers – If you want to change both the content and the HTML element itself, you use the outerHTML property object.outerHTML = content; New Perspectives on HTML, XHTML, and Dynamic HTML, 4e8

XP Working with Nodes A node represents an object within the Web page and Web browser The text within an HTML tag can also be treated as a node. For example, the tag Table of Contents consists of two nodes: one node for the h1 element and one node for the text string, Table of Contents, contained within that element New Perspectives on HTML, XHTML, and Dynamic HTML, 4e9

XP New Perspectives on HTML, XHTML, and Dynamic HTML, 4e10 Working with Nodes The Node Tree – Nodes are arranged into a hierarchal structure called a node tree, which indicates the relationship between each of the nodes

XP Working with Nodes The Node Tree – The parent of all nodes within a document is the root node New Perspectives on HTML, XHTML, and Dynamic HTML, 4e11

XP Working with Nodes Node types, names, and values New Perspectives on HTML, XHTML, and Dynamic HTML, 4e12

XP Working with Nodes Node types, names, and values New Perspectives on HTML, XHTML, and Dynamic HTML, 4e13

XP Working with Nodes Creating and Attaching Nodes New Perspectives on HTML, XHTML, and Dynamic HTML, 4e14

XP Working with Nodes Creating and Attaching Nodes – Unattached nodes and node trees are known as document fragments and exist only in a browser’s memory New Perspectives on HTML, XHTML, and Dynamic HTML, 4e15

XP Working with Nodes Creating and Attaching Nodes New Perspectives on HTML, XHTML, and Dynamic HTML, 4e16

XP Creating a List of Heading Elements Looping Through the Child Node Collection New Perspectives on HTML, XHTML, and Dynamic HTML, 4e17

XP Creating a List of Heading Elements Matching the Heading Elements New Perspectives on HTML, XHTML, and Dynamic HTML, 4e18

XP Creating a List of Heading Elements Creating the List Item Elements New Perspectives on HTML, XHTML, and Dynamic HTML, 4e19

XP Creating a Nested List New Perspectives on HTML, XHTML, and Dynamic HTML, 4e20

XP Creating a Nested List New Perspectives on HTML, XHTML, and Dynamic HTML, 4e21

XP Creating a Nested List New Perspectives on HTML, XHTML, and Dynamic HTML, 4e22

XP Creating a Nested List New Perspectives on HTML, XHTML, and Dynamic HTML, 4e23

XP Creating a Nested List New Perspectives on HTML, XHTML, and Dynamic HTML, 4e24

XP Creating a Nested List New Perspectives on HTML, XHTML, and Dynamic HTML, 4e25

XP Working with Attributes New Perspectives on HTML, XHTML, and Dynamic HTML, 4e26

XP Working with Attributes Attribute Nodes New Perspectives on HTML, XHTML, and Dynamic HTML, 4e27

XP Working with Attributes Attribute Nodes New Perspectives on HTML, XHTML, and Dynamic HTML, 4e28

XP Working with Attributes Attributes as Object Properties – The document object model also supports a shorthand way of applying attributes as properties of an object object.attr = value; – To test whether the listItem node has an id attribute, you can use the following expression: listItem.hasAttribute(“id”) New Perspectives on HTML, XHTML, and Dynamic HTML, 4e29

XP Working with Attributes Setting the Section Heading IDs New Perspectives on HTML, XHTML, and Dynamic HTML, 4e30

XP Working with Attributes Inserting Links New Perspectives on HTML, XHTML, and Dynamic HTML, 4e31

XP Working with Attributes Inserting Links New Perspectives on HTML, XHTML, and Dynamic HTML, 4e32

XP Expanding and Collapsing a Document New Perspectives on HTML, XHTML, and Dynamic HTML, 4e33

XP Expanding and Collapsing a Document Creating a plus/minus Box New Perspectives on HTML, XHTML, and Dynamic HTML, 4e34

XP Expanding and Collapsing a Document Creating a plus/minus Box New Perspectives on HTML, XHTML, and Dynamic HTML, 4e35

XP Expanding and Collapsing a Document Adding Event Handlers to the plus/minus Boxes New Perspectives on HTML, XHTML, and Dynamic HTML, 4e36

XP Expanding and Collapsing a Document Hiding and Display Objects New Perspectives on HTML, XHTML, and Dynamic HTML, 4e37

XP Expanding and Collapsing a Document Expanding and Collapsing the Source Document New Perspectives on HTML, XHTML, and Dynamic HTML, 4e38

XP Expanding and Collapsing a Document Expanding and Collapsing the Source Document New Perspectives on HTML, XHTML, and Dynamic HTML, 4e39

XP Expanding and Collapsing a Document Testing the Dynamic TOC New Perspectives on HTML, XHTML, and Dynamic HTML, 4e40

XP Traversing the Node Tree with Recursion Recursion is a programming technique in which a function calls itself repeatedly until a stopping condition is met New Perspectives on HTML, XHTML, and Dynamic HTML, 4e41

XP Switching Between Style Sheets New Perspectives on HTML, XHTML, and Dynamic HTML, 4e42

XP Switching Between Style Sheets Style sheets can be classified as persistent, preferred, and alternate: – Persistent style sheets are always active – Preferred style sheets are turned on by default, but can be turned off by actions of the user – Alternate style sheets are not turned on by default, but can be turned on as an alternate to the preferred style sheet New Perspectives on HTML, XHTML, and Dynamic HTML, 4e43

XP Switching Between Style Sheets New Perspectives on HTML, XHTML, and Dynamic HTML, 4e44

XP Switching Between Style Sheets Code to populate the allStyles array New Perspectives on HTML, XHTML, and Dynamic HTML, 4e45

XP Switching Between Style Sheets Creating a form button for each style sheet New Perspectives on HTML, XHTML, and Dynamic HTML, 4e46

XP Switching Between Style Sheets You can disable a style sheet using the command styleSheet.disabled = true You can enable it with the command styleSheet.disabled = false Code to initialize the style sheets New Perspectives on HTML, XHTML, and Dynamic HTML, 4e47

XP Switching Between Style Sheets Code to switch between styles New Perspectives on HTML, XHTML, and Dynamic HTML, 4e48

XP Switching Between Style Sheets Properties of the style sheet object New Perspectives on HTML, XHTML, and Dynamic HTML, 4e49