JavaScript Document Object Properties
In this JavaScript tutorial, you will learn about Document Object Properties viz. formName, forms, images, lastModified, layers, linkColor, links, plugins, referrer, title, URL and vlinkColor.
formName:
Using the formName property, any form in the document can be referred and the formName is assigned as <FORM NAME = "formID">.
General syntax for using the formName property is as follows:
|
forms:
When a programmer wants to refer all the Form objects in a current document, then he or she can make use of the forms property. The forms property is an array that gives reference to all Form objects associated with the current document.
General syntax for using the forms property is as follows:
|
images:
When a programmer wants to refer all the Image objects in a current document then he or she can make use of the forms property. The images property is an array that gives reference to all Image objects associated with the current document.
General syntax for using the images property is as follows:
|
lastModified:
The lastModified property returns the document’s last modified date and time.
General syntax for using the lastModified property of a document object is as follows:
|
for example
|
The output of the above program is
|
In the above program, the latest modified date and time of the document displays.
layers:
When a programmer wants to refer all the Layer objects in a current document, then he or she can make use of the layers property. The layers property is an array that gives reference to all Layer objects associated with the current document.
General syntax for using the layers property is as follows:
|
linkColor:
Just as there is an option to define the color of an active link there is also an option to define the color of hyperlinks in a document. The linkColor property can be used to define the color of hyperlinks in a document.
The general syntax for using the linkColor property of document object is as follows:
|
Here, the "Information of color" is a string that is given either as a hexadecimal representation or directly as a literal description denoting the color of the hyperlink link needed.
links:
The links property is an array that gives reference to all the Area and Link objects in the current document.
General syntax for using the links property of a document object is as follows:
|
plugins:
When a programmer wants to refer all the Plugin objects to a current document then he or she can make use of this plugins property. The plugins property is an array that gives reference to all Plugin objects associated with the current document.
General syntax for using the plugins property is as follows:
|
referrer:
Just as we had the domain property to return the domain name of the document if the programmer wants to have the URL of the document that loaded the current document, then the referrer property can be used. If a destination document is reached when a user clicks on a Link object in another document (the referrer) then, when the referrer property is used, this returns to the referring document’s URL.
General syntax for using the referrer property of document object is as follows:
|
{mospagebreak title=Properties: title, URL and vlinkColor}
title:
The title of the current document can be returned by using the title property. The title property returns the name as defined between the <TITLE></TITLE> tags.
The general syntax for using the title property of a document object is as follows:
|
for example
|
The output of the above program is:
|
In the above program, the title of the document ( Exforsys) is placed between the tags and <title> and </title> is displayed.
URL:
The property URL returns the URL of the current document.
The general syntax for using the URL property of document object is as follows:
|
vlinkColor:
If a programmer wants to define the color of any visited links in the document, then the vlinkColor property can be used for this. The vlinkColor property can be used to define the color of any visited links in the document.
General syntax for using the vlinkColor property of document object is as follows:
|
Here, the "Information of color" is a string that is given either as a hexadecimal representation, or directly, as literal description denoting the foreground color of the document needed.