Javascript Dom

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

JAVASCRIPT DOM

WHAT IS DOM
• Documet -> Just like a file
• Object-> is anything you put inside html document
• Model-> layout of its structure

<html>
<head></head>
<body></body>
</html>
For head and body html is direct parent
<html>
<head>
<title></title>
</head>
<body>
<h1></h1>
<p></p>
</body>
</html>
• <title> parent is <head>
• <h1><p> parent is <body>
SO DOM IS USED TO SHOW HIERARCHICAL RELATIONSHIP AMONG
ELEMENTS
Properties
• It is an application programming interface for HTML & XML
documents
• Used to Navigate through structure of document, add , modify and
delete elements dynamically
• It is object oriented representation of web pages
• Used to represent document with a logical tree
• Treat every HTML tag as object
• Access properties of these objects using built in methods of objects
• Functionality of objects can be controlled dynamically
Navigator

Window

Document

Head Body

Title H1 P

text text text

Window.document.head.title.text=HTML
Structure of DOM
JSS DOM
JSSS DOM
Exercise : Change the checked value of checkbox and radio button
Window Object window.open()

window.close()
window.innerHeight
window.moveTo()
WINDOW
window.resizeTo() window.innerWidth

DOCUMENT LOCATION
HISTORY

∙ history.back() - same as clicking back in the


•window.location.href returns the href (URL) of the current page
browser
∙ history.forward() - same as clicking forward in •window.location.pathname returns the path and filename of the
current page
the browser •window.location.assign() loads a new document
•window.location.protocol returns the web protocol used (http: or
https:)
•window.location.hostname returns the domain name of the web
host
Example
Built-In Objects
1. String
2. Maths
3. Date
4. Array

You might also like