I am new to JavaScript and I have Googled DOM and found many websites stating that it is a interface/API against an XML/HTML document. However I do not understand what DOM is. Is it the name of the API? Is it a specification that browsers need to follow? Could somebody explain that?
Also, am I using the DOM API directly when writing document.get... or am is that JavaScript which wraps a call to the DOM API?
If anyone could explain how DOM and JavaScript works together and what it is I would really appreciate your help!
The Document Object Model, or DOM, is the interface that allows you to programmatically access and manipulate the contents of a web page (or document). It provides a structured, object-oriented representation of the individual elements and content in a page with methods for retrieving and setting the properties of those objects. It also provides methods for adding and removing such objects, allowing you to create dynamic content.
The DOM is an API exposed by browsers. It’s seperate from ECMAScript and it’s a well defined specification in the W3C standards.
The API that’s exposed by browsers is an implementation of the DOM. One could argue whether or not the implementation is at the C++ level and whether the javascript API is a proxy or not but that isn’t an interesting argument.
Generally the DOM and BOM as well as various html5 specification form the host objects that browsers expose through properties on
windowAnd the host objects are nothing more then the innards a browser is exposing to you so you can manipulate the state of the browser, the state of the page and do communication with outside resources.