Javascript Document


The browser opens an HTML document, which becomes a document object, which allows us to access all the elements in the HTML page.

Tip: The document object is part of the window object, which can be accessed through the window.document property, but usually omitting the window.

Document object collection

Collection Description Description
all[] Provides an array of access to all HTML elements in the document has been less applicable
anchors[] An array of all Anchor objects referenced in the document None
forms[] An array of all Form object references in the document None
images[] Array of all Image objects referenced in the document None
links[] An array of all Area and Link object references in the document None

Document object property

Properties Description Description
cookie Set or get all the cookies associated with the current document None
domain Get the current document's domain name None
lastModified Get the date and time the document was last modified Different browser results may be different
referrer gets the URL of the current document (previous URL address) None
title Get the title of the current document None
URL Get the current document URL None

Document object method

method Description Description
getElementById() Get the element (first) object from element id The W3C specification requires that id be unique
getElementsByName() Get a collection of element objects from element name None
getElementsByTagName() Get the collection of element objects according to the specified tag name None
open() Opens a data stream to gather output from any document.write() or document.writeln() method None
write() Write an HTML expression or JavaScript code to the document None
writeln() is equivalent to the write() method, except that after each expression a newline None
close() Close the output stream opened with the document.open() method and display the selected data None



Copyright 2014-2017 by DeveloperTut.com. All Rights Reserved.
TwitterGoogle+Facebook