DOM stands for Document Object Model. It is a standard defined by
W3C (World Wide Web Consortium). DOM is a programming interface (API) for representing and interacting with HTML, XHTML and XML documents. It organize the elements of the document in tree structure (DOM tree) and in the DOM tree, all elements of the document are defined as
objects (tree nodes) which have properties and methods.
Here, I am sharing
some DOM API's objects, methods and properties.
DOM API Objects
The window object represents an open window containing a DOM document.
The document object represents the HTML document in a specific window.
This object contains information about the URLs visited by the client.
This object contains information about the current URL.
This object contains information about the client.
DOM API Methods
DOM methods are actions which you can perform on document elements.
This method appends an element as a child to the object..
This method creates an instance of the element for the specified tag.
This method reloads the current document.
This method removes the object from the document hierarchy..
DOM API Properties
HTML DOM properties are values (of document Elements) that you can set or change
This property retrieves the name of the client.
This property Retrieves the platform and version of the application.
This property sets or retrieves the entire URL as a string.
DOM API Example
When a web page is loaded, the browser creates a DOM tree for all the objects (Html elements) of that page. The HTML DOM is a fully
object-oriented representation of your web page and in HTML DOM each and everything is a node. DOM tree nodes can be removed, added, and replaced by using DOM API.
Types of HTML DOM Tree Nodes
This node represents the HTML document.
This node represents an HTML element.
This node represents an HTML element's attribute.
This node represents Text inside an HTML element.
This node represents HTML Comment.
A Simple DOM Tree
<HTML> <HEAD> <TITLE>Your Title</TITLE> <SCRIPT src="www.webgeekschool.com/jsfile.js"></SCRIPT> </HEAD> <BODY> <DIV>Your Div Text</DIV> <P>Your Para Text</p> </BODY> </HTML>
DOM tree representaion of above web page is given below:
BOM stands for Browser Object Model. Unlike DOM, there is no standard defined for BOM, hence different browsers implement it in different ways. Typically, the collection of browser objects is collectively known as the Browser Object Model.
BOM main task is to manage browser windows and enable communication between the windows. Each HTML page which is loaded into a browser window becomes a
Document object and document object is an object in the BOM. You can say BOM is super set of DOM. BOM has many objects, methods, and properties that are not the part of the DOM structure.
The important BOM objects are as:
BOM Objects Example
What do you think?
I hope, now you have the better understanding of DOM and BOM. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.