SlideShare a Scribd company logo
Document Object Model
CONTENTS
1.WHAT IS DOCUMENT OBJECT MODEL ?
2.WHERE THE DOM CAME FROM ?
3.HOW THE WEBPAGE IS LOADED AND DISPLAYED?
3.1. THE REQUEST
3.2. THE RESPONSE
3.3. THE PARSING
3.4 THE BUILT
4.WHAT IS NODE ?
5.ADDING SOME TEXT TO A PAGE
6.BEST WAY TO THE GET ELEMENT
7.CONCLUSION
8.REFERENCES
2
What is Document Object Model ?
 Document Object Model (DOM), a programming interface specification
being developed by the World Wide Web Consortium (W3C).
 DOM is the browser’s internal programmatic representation of the
Webpage.
 Can be manipulated by language like JavaScript.
 Set of hierarchical collection of objects/elements.
3
WheretheDocumentObjectModelcamefrom?
"browser wars" of the late 1990s between Netscape Navigator
and Microsoft Internet Explorer.
1996 within Netscape Navigator 2.0
“DOM Level 0" or "Legacy DOM”
W3C in late 1998 - > 2000 introduce.. DOM Level 1 and 2.
2005, large parts of W3C DOM were well-supported
by common ECMAScript-enabled browsers
4
HOWTHEWEBPAGEISLOADEDANDDISPLAYED?
Technically there are four steps of a webpage being displayed
 Request
 Response
 Built
 Render
Each of these steps are often performed several times during a page load.
5
The Request
 The most common way a webpage is requested is when a link is clicked,
but requests also occur when a page is refreshed, or when a url is typed
into a browser.
 The moment when a webpage is requested is also called "navigation
start".
 It is basically the moment where the whole process of displaying a page
begins.
 When a linked is clicked a request is made for a document
6
The Response
 The web server then provides the file to the web browser. The response
is simply the browser receiving the thing it had requested.
 However, most webpages have things like images, videos, flash movies ,
External CSS and External JavaScript file.
 These are called resources and in order to display the webpage the web
browser must get those page resources as well.
7
Parsing
 Translate the HTML into series of recognizable tokens
 The web browser looks at the entire HTML document and looks for any
CSS, JavaScript and images that are referenced by the page.
 The images, CSS, and JavaScript that the HTML file references will be
downloaded by the browser.
 It’s main job is to recognizable token into tree of related object
8
The Build
There are basically three steps that the browser takes to build a page.
 Build the DOM
 Build the CSSOM
 Build the Render Tree
9
Building the DOM
 The Rendering engine will then use that tree of object to determine
where we position element on screen.
 The developer then able to use JavaScript to interact with tree of
related object through number of properties and method
 Each object inherits at the point it was instantiated
10
<!DOCTYPE html>
<html>
<head>
<title>Understanding the Document Object Model</title>
<script type="text/javascript" src="script13.js"></script>
</head>
<body>
<h1 id="title“>Understanding the Document ObjectModel</h1>
<p id="first">This is the first paragraph</p>
<p id="second">
<strong>Second paragraph</strong>
</p>
<p id="third">Third paragraph</p>
<input type="submit" id="clickMe" value="Click Me" />
<a href="http://www.bing.com" id="myAnchor">Bing!</a>
</div>
</body>
</html>
11
Hierarchyof an exampleof DOM
12
13
What is a Node?
The DOM presents documents as a hierarchy of Node objects that also
implement other, more specialized interfaces.
 Element Node – contains an HTML tag
 Text Node – contains text
 Text Nodes are contained in Element Nodes
14
Adding Some Text To A Page
 Create a new Element
[document.createElement(“p”)]
 Create a Text Node
[document.createTextNode(“Some text.”) ]
 Attach the New Text Node to the New Element
[newNode.appendChild(newText)]
 Find an Existing Element
[document.getElementById(“thisLocation”)]
15
Best way to the get Element
getElementById() allows you to work with elements by
their individual id but often you will want to work with a
group of elements
var clickMeButton = document.getElementById('clickMe');
getElementsByTagName() allows you to work with
groups of elements. This method returns an array
16
Early Lifecycle of Web page
17
CONCLUSION
There's much more to the Document Object Model than what's been
covered here. Styles add a whole new dimension to content
presentation and events provide a means to make pages interactive with
the user. But these topics deserve their own discussion. The methods
provided to navigate it and manipulate different types of nodes. This will
give you a solid foundation for dealing with other features of the DOM
18
REFERENCES
1. https://en.wikipedia.org/wiki/Document_Object_Model
2. https://www.youtube.com/watch?v=SmE4OwHztCc
3. https://www.w3c.org/DOM/
4. https://varvy.com/pagespeed/display.html
19
20

More Related Content

PDF
Php introduction
PPTX
Html5 and-css3-overview
PPTX
Html coding
PPT
Javascript
PPTX
Dynamic HTML (DHTML)
ODP
PDF
JavaScript - Chapter 13 - Browser Object Model(BOM)
Php introduction
Html5 and-css3-overview
Html coding
Javascript
Dynamic HTML (DHTML)
JavaScript - Chapter 13 - Browser Object Model(BOM)

What's hot (20)

PDF
JavaScript - Chapter 11 - Events
PDF
Html / CSS Presentation
PPT
Css Ppt
PDF
JavaScript - Chapter 8 - Objects
PPT
JavaScript - An Introduction
PPTX
Lab #2: Introduction to Javascript
PPT
CSS for Beginners
PPTX
Flexbox
PPT
JavaScript & Dom Manipulation
PPTX
Javascript 101
PPTX
Dom(document object model)
PPT
Document Object Model
PDF
Intro to HTML & CSS
PPTX
The Complete HTML
PPTX
An Introduction to the DOM
PPT
Asp.net.
PPTX
HTML: Tables and Forms
PPTX
HTML (Web) basics for a beginner
JavaScript - Chapter 11 - Events
Html / CSS Presentation
Css Ppt
JavaScript - Chapter 8 - Objects
JavaScript - An Introduction
Lab #2: Introduction to Javascript
CSS for Beginners
Flexbox
JavaScript & Dom Manipulation
Javascript 101
Dom(document object model)
Document Object Model
Intro to HTML & CSS
The Complete HTML
An Introduction to the DOM
Asp.net.
HTML: Tables and Forms
HTML (Web) basics for a beginner
Ad

Viewers also liked (20)

PPT
DOM ( Document Object Model )
PPTX
Document object model(dom)
PPTX
PDF
Javascript and DOM
PDF
Document Object Model (DOM) Level 1 Specification
PPT
Document Object Model
PPT
XML and XPath details
PDF
JavaScript and DOM
PPTX
HTML Block and Inline Elements
PPT
Understanding XML DOM
PPT
PPT
PPT
XPath - XML Path Language
PPTX
PPTX
Overview of XSL, XPath and XSL-FO
PDF
JavaScript DOM & event
PDF
學習JavaScript_Dom
PDF
Javascript, DOM, browsers and frameworks basics
DOM ( Document Object Model )
Document object model(dom)
Javascript and DOM
Document Object Model (DOM) Level 1 Specification
Document Object Model
XML and XPath details
JavaScript and DOM
HTML Block and Inline Elements
Understanding XML DOM
XPath - XML Path Language
Overview of XSL, XPath and XSL-FO
JavaScript DOM & event
學習JavaScript_Dom
Javascript, DOM, browsers and frameworks basics
Ad

Similar to Document Object Model (20)

PDF
Javascript projects Course
PPTX
Web components
PPTX
HTML.pptx
PPTX
Building high performance web apps.
PPT
Introduction To Dojo
PPTX
Modern Web Technologies
PPTX
Document object model
PPTX
Javascript for web Programming creating and embedding with html
PPTX
Understanding the dom by Benedict Ayiko
PDF
Intro to mobile web application development
DOCX
How Browsers Work -By Tali Garsiel and Paul Irish
PPTX
Unlearning and Relearning jQuery - Client-side Performance Optimization
PPTX
Web technologies part-2
PDF
Week 05 Web, App and Javascript_Brandon, S.H. Wu
PPTX
chap08 - Javascript. YfugffuuhuiDOM.pptx
PPTX
Jquery dojo slides
PPTX
Internet protocol second unit IIPPT.pptx
PDF
Website designing company in faridabad
Javascript projects Course
Web components
HTML.pptx
Building high performance web apps.
Introduction To Dojo
Modern Web Technologies
Document object model
Javascript for web Programming creating and embedding with html
Understanding the dom by Benedict Ayiko
Intro to mobile web application development
How Browsers Work -By Tali Garsiel and Paul Irish
Unlearning and Relearning jQuery - Client-side Performance Optimization
Web technologies part-2
Week 05 Web, App and Javascript_Brandon, S.H. Wu
chap08 - Javascript. YfugffuuhuiDOM.pptx
Jquery dojo slides
Internet protocol second unit IIPPT.pptx
Website designing company in faridabad

Recently uploaded (20)

PPTX
Introduction to cybersecurity and digital nettiquette
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PDF
The Ikigai Template _ Recalibrate How You Spend Your Time.pdf
PDF
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
PPTX
Internet___Basics___Styled_ presentation
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
artificialintelligenceai1-copy-210604123353.pptx
PPTX
newyork.pptxirantrafgshenepalchinachinane
PDF
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
PDF
Exploring VPS Hosting Trends for SMBs in 2025
DOCX
Unit-3 cyber security network security of internet system
PPTX
Power Point - Lesson 3_2.pptx grad school presentation
DOC
Rose毕业证学历认证,利物浦约翰摩尔斯大学毕业证国外本科毕业证
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PPTX
E -tech empowerment technologies PowerPoint
PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
Funds Management Learning Material for Beg
Introduction to cybersecurity and digital nettiquette
SASE Traffic Flow - ZTNA Connector-1.pdf
The New Creative Director: How AI Tools for Social Media Content Creation Are...
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
The Ikigai Template _ Recalibrate How You Spend Your Time.pdf
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
Internet___Basics___Styled_ presentation
INTERNET------BASICS-------UPDATED PPT PRESENTATION
artificialintelligenceai1-copy-210604123353.pptx
newyork.pptxirantrafgshenepalchinachinane
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
Exploring VPS Hosting Trends for SMBs in 2025
Unit-3 cyber security network security of internet system
Power Point - Lesson 3_2.pptx grad school presentation
Rose毕业证学历认证,利物浦约翰摩尔斯大学毕业证国外本科毕业证
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
E -tech empowerment technologies PowerPoint
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
SAP Ariba Sourcing PPT for learning material
Funds Management Learning Material for Beg

Document Object Model

  • 2. CONTENTS 1.WHAT IS DOCUMENT OBJECT MODEL ? 2.WHERE THE DOM CAME FROM ? 3.HOW THE WEBPAGE IS LOADED AND DISPLAYED? 3.1. THE REQUEST 3.2. THE RESPONSE 3.3. THE PARSING 3.4 THE BUILT 4.WHAT IS NODE ? 5.ADDING SOME TEXT TO A PAGE 6.BEST WAY TO THE GET ELEMENT 7.CONCLUSION 8.REFERENCES 2
  • 3. What is Document Object Model ?  Document Object Model (DOM), a programming interface specification being developed by the World Wide Web Consortium (W3C).  DOM is the browser’s internal programmatic representation of the Webpage.  Can be manipulated by language like JavaScript.  Set of hierarchical collection of objects/elements. 3
  • 4. WheretheDocumentObjectModelcamefrom? "browser wars" of the late 1990s between Netscape Navigator and Microsoft Internet Explorer. 1996 within Netscape Navigator 2.0 “DOM Level 0" or "Legacy DOM” W3C in late 1998 - > 2000 introduce.. DOM Level 1 and 2. 2005, large parts of W3C DOM were well-supported by common ECMAScript-enabled browsers 4
  • 5. HOWTHEWEBPAGEISLOADEDANDDISPLAYED? Technically there are four steps of a webpage being displayed  Request  Response  Built  Render Each of these steps are often performed several times during a page load. 5
  • 6. The Request  The most common way a webpage is requested is when a link is clicked, but requests also occur when a page is refreshed, or when a url is typed into a browser.  The moment when a webpage is requested is also called "navigation start".  It is basically the moment where the whole process of displaying a page begins.  When a linked is clicked a request is made for a document 6
  • 7. The Response  The web server then provides the file to the web browser. The response is simply the browser receiving the thing it had requested.  However, most webpages have things like images, videos, flash movies , External CSS and External JavaScript file.  These are called resources and in order to display the webpage the web browser must get those page resources as well. 7
  • 8. Parsing  Translate the HTML into series of recognizable tokens  The web browser looks at the entire HTML document and looks for any CSS, JavaScript and images that are referenced by the page.  The images, CSS, and JavaScript that the HTML file references will be downloaded by the browser.  It’s main job is to recognizable token into tree of related object 8
  • 9. The Build There are basically three steps that the browser takes to build a page.  Build the DOM  Build the CSSOM  Build the Render Tree 9
  • 10. Building the DOM  The Rendering engine will then use that tree of object to determine where we position element on screen.  The developer then able to use JavaScript to interact with tree of related object through number of properties and method  Each object inherits at the point it was instantiated 10
  • 11. <!DOCTYPE html> <html> <head> <title>Understanding the Document Object Model</title> <script type="text/javascript" src="script13.js"></script> </head> <body> <h1 id="title“>Understanding the Document ObjectModel</h1> <p id="first">This is the first paragraph</p> <p id="second"> <strong>Second paragraph</strong> </p> <p id="third">Third paragraph</p> <input type="submit" id="clickMe" value="Click Me" /> <a href="http://www.bing.com" id="myAnchor">Bing!</a> </div> </body> </html> 11
  • 13. 13
  • 14. What is a Node? The DOM presents documents as a hierarchy of Node objects that also implement other, more specialized interfaces.  Element Node – contains an HTML tag  Text Node – contains text  Text Nodes are contained in Element Nodes 14
  • 15. Adding Some Text To A Page  Create a new Element [document.createElement(“p”)]  Create a Text Node [document.createTextNode(“Some text.”) ]  Attach the New Text Node to the New Element [newNode.appendChild(newText)]  Find an Existing Element [document.getElementById(“thisLocation”)] 15
  • 16. Best way to the get Element getElementById() allows you to work with elements by their individual id but often you will want to work with a group of elements var clickMeButton = document.getElementById('clickMe'); getElementsByTagName() allows you to work with groups of elements. This method returns an array 16
  • 17. Early Lifecycle of Web page 17
  • 18. CONCLUSION There's much more to the Document Object Model than what's been covered here. Styles add a whole new dimension to content presentation and events provide a means to make pages interactive with the user. But these topics deserve their own discussion. The methods provided to navigate it and manipulate different types of nodes. This will give you a solid foundation for dealing with other features of the DOM 18
  • 19. REFERENCES 1. https://en.wikipedia.org/wiki/Document_Object_Model 2. https://www.youtube.com/watch?v=SmE4OwHztCc 3. https://www.w3c.org/DOM/ 4. https://varvy.com/pagespeed/display.html 19
  • 20. 20