Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to the Document Object Model DOM *Understand document structure manipulation *Dynamic effects in web pages *Programming, scripting, web content.

Similar presentations


Presentation on theme: "Introduction to the Document Object Model DOM *Understand document structure manipulation *Dynamic effects in web pages *Programming, scripting, web content."— Presentation transcript:

1 Introduction to the Document Object Model DOM *Understand document structure manipulation *Dynamic effects in web pages *Programming, scripting, web content concepts

2 TAGS to OBJECTS A document is read in by a browser. The browser builds an object hierarchy of the document. Each tag is converted to an object. Objects are memory structures which have - properties =data values -methods = code the object can execute -event/handlers= respond to something done to the object -address = a means of identifying the object in the document hello world Browser Window Document Body header

3 Document Reference Problem DOM Example hello world this is an object to click OBJECT How to specify what? How to specify where?

4 How to Specify Where? DOM Example hello world this is an object to click 1) By name or ID Example: 2) Object Hierarchy html headbody titleh1 p a

5 Object Hierarchy Dot Notation html headbody titleh1 p a.document elements Collections of specific elements.all[].links[].forms[] … All[6] - 6th element in “all” depth first search Document.links[0] - use the links collection Alternative Location specifications using collections. For example the tag can be specified by

6 DOM a Brief List.window.document.forms[].images[].links[].frame.document.all[].elements Document: Method -.write() Properties -.bgColor Elements: handler – onSubmit() Properties -.value.all[] refers to any tag, addresses by [occurrence number] or “ID” Properties- any style handler - onClick

7 How to Specify What? this is an object to click Special content designations: innerText, innerHTML Properties: bgcolor, color Events: onclick

8 DOMExample.html DOM Example hello world Click on this text to change the color Click on this to change the background color Click on this to make hello world green Click on this to make line2 green

9 Document Object Model Tutorials http://www.csctce.com/demos/dom_tutorial/ http://hotwired.lycos.com/webmonkey/97/32/index1a.html?tw=authoring http://www.w3schools.com/dhtml/dhtml_events.asp http://www.brainjar.com/dhtml/intro/default.asp Tutorials designed to increase your familiarity with the Document Object Models (DOMs) used by Netscape and Microsoft web browsers The DOM is extensively described and used in Chapters 14 to 20 of Deitel “Internet and the World Wide Web How to Program” also see the first section of Java Script in Greenlaw

10 More Events and Properties Event Handlers: ONMOUSEMOVE - fires when curser moves ONMOUSEOVER - Fires when curser moves over an element ONMOUSEOUT - Fires when curser leaves an object ONKEYDOWN - Fires when the user pushes a key ONCLICK – Fires when object is clicked Style Properties: In general if a style is dashed in CSS it is lowerCamelCased in the DOM JScript. So in CSS Text-Decoration:underline in DOM becomes textDecoration=‘underline’


Download ppt "Introduction to the Document Object Model DOM *Understand document structure manipulation *Dynamic effects in web pages *Programming, scripting, web content."

Similar presentations


Ads by Google