JavaScript Document Object Properties

The document object provides various properties that are related to an HTML document such as title property, url property, etc.

The property is accessed by using the notation given here:

objectName.propertyName

Here, objectName is the name of the object and the propertyName is the name of its property. Both are case-sensitive.

The following table lists the properties of the Document object in JavaScript.

Property Description
cookie returns a report that contains all the visible and unexpired cookies associated with the document
domain returns the domain name of the server from which the document has originated
lastModified returns the date on which the document was last modified
documentMode returns the mode used by the browser to process the document
readyState returns the loading status of the document
referrer returns the URL of all the documents referred to in an HTML document
title returns the name of the HTML document defined between the starting and ending tags of the TITLE element
URL returns the full URL of the HTML document

JavaScript Document Object Properties

Here is an example demonstrates document object properties in JavaScript:

<!DOCTYPE HTML>
<html>
<head>
   <title>JavaScript Document Object Properties</title>
</head>
<body>

<h3>JavaScript Document Object Properties Example</h3>
<p>The URL of this document is:<br/>
<script type="text/javascript">
   document.write(document.URL);
</script></p>
<p>Loading status:<br/>
<script type="text/javascript">
   document.write(document.readyState);
</script></p>
<p>The title of this document is:<br/>
<script type="text/javascript">
   document.write(document.title);
</script></p>

</body>
</html>

Here is the sample output of the above JavaScript document object properties example:

javascript document object properties

JavaScript Online Test


« Previous Tutorial Next Tutorial »