HTML DOM Document Object
Document Object
Each HTML document that is loaded into the browser becomes the document object.
The Document object allows us to access all elements of an HTML page from within a script.
Document Object Collection
HTML DOM Forms Collection
The Forms collection returns a reference to all Form objects in the document.
Document.forms[] Instances
HTML DOM Images Collection
The images collection returns a reference to all the Image objects in the document.
Instance
<body><br /><br /><br /><script type="text/javascript">document.write("This document contains: ")document.write(document.images.length + " images.")</script></body>
HTML DOM Cookie Properties
The cookie attribute sets or queries all cookies that are relevant to the current document.
Example the cookies associated with this document are:
HTML DOM Domain Property
The Domain property returns the name of the server that downloaded the current document.
Instance
HTML DOM getElementById () method
The getElementById () method returns a reference to the first object that owns the specified ID.
Grammar
document.getElementById(id)
HTML DOM Getelementsbyname () method
The Getelementsbyname () method can return a collection of objects with the specified name.
Grammar
document.getElementsByName(name)
HTML DOM getElementsByTagName () method
The getElementsByTagName () method returns a collection of objects with the specified label name.
Grammar
document.getElementsByTagName(tagname)
HTML DOM Open () method
The open () method opens a new document and erases the contents of the current document.
Grammar Document.open (Mimetype,replace)
Important: When the open () method is called and the document content is set using the Write () method, you must remember to close the document with the Close method and force its contents to appear.
Note: A script or event handle that is part of an overridden document cannot call the method because the script or event handle itself is overwritten.
Instance
HTML DOM Close () method
The close () method closes an output stream opened by the Document.open method and displays the selected data.
Grammar Document.close ()
Description
This method closes the document stream opened by the open () method and forces the output of all caches to be displayed. If you use the Write () method to output a document dynamically, you must remember to call the close () method when you do so to ensure that all document content is displayed.
Once close () is called, write () should not be called again because it implicitly calls open () to erase the current document and start a new document.
Instance
HTML DOM Write () method
The write () method writes an HTML expression or JavaScript code to a document.
Multiple parameters (Exp1,exp2,exp3,...) can be listed, which are appended sequentially to the document.
Grammar document.write (Exp1,exp2,exp3,....) Description Although the method accepts only a single string as a parameter, according to the DOM standard. However, based on experience, write () can accept any number of parameters.
We usually use the write () method in two ways: one is to use that side to output HTML in the document, and the other is to create a new document in a window, frame, outside the window that calls the method. In the second case, be sure to close the document using the close () method.
Instance
HTML DOM Document Object