### Document Object

##### Description

> An object that resides below the window in the scripting object model. A document may contain:

> - Link - Array of hyperlinks found on the given document.
> - Anchor - Array of anchors found on the given document.
> - Form - Array of forms found on the given document.

> The document object reflects the HTML document currently in the browser and objects on the page— links, forms, buttons, and ActiveX objects. Methods and properties of the document object must be called in a script by placing document first in the statement. This means that if you wanted to set the background color on the page, the script would look like:

>     <script language="VBScript">
>          document.bgColor = "Blue"
>     </script>

> The document object currently has no events.

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, title, cookie, referrer

### Properties

### linkColor Property

##### Description

> Gets or sets the current color of the links in a document.

##### Syntax

> document.linkColor [=rgb-value|string]

> Part | Description
> document | An object expression that evaluates to a document object.
> rgb-value | Optional. The new color of links in the document.
> string | Optional. A string value specifying the color.

##### Return Value

> Returns the rgb value of the current link color.

##### Remarks

> Note that this property can only be set at parse time, not after the page is painted. So the code:

>     <SCRIPT LANGUAGE="JScript">
>     document.vLinkColor = "green";
>     document.linkColor = "red";
>     document.alinkColor = "aqua";
>     </SCRIPT>

> sets the link color, while the code:

>     <FORM>
>     "document.linkColor='#000000'">
>     <INPUT TYPE="button" VALUE="Set Visited Link Color to White" onClick = "document.vLinkColor='#AAAAAA'">
>     </FORM>

> will have no effect when the button is clicked.

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, title, cookie, referrer

### aLinkColor Property

##### Description

> Gets or sets the current color of the active links in a document. A link is active when the pointer is positioned over it and the mouse button is pressed and not released. Note that Internet Explorer does not have this feature, so aLinkColor has no effect; however, it is supported in the object model for compatibility reasons. As with linkColor, this property can only be set at parse time. See the examples in linkColor for details.

##### Syntax

> document.aLinkColor [=rgb-value|string]

> Part | Description
> document | An object expression that evaluates to a document object.
> rgb-value | Optional. The new color of links in the document.
> string | Optional. A string value specifying the color.

##### Return Value

> Returns the rgb value of the current link color.

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, title, cookie, referrer

### vLinkColor Property

##### Description

> Gets or sets the current color of the visited links in a document. As with linkColor, this property can only be set at parse time. See the examples in linkColor for details.

##### Syntax

> document.vLinkColor [=rgb-value|string]

> Part | Description
> document | An object expression that evaluates to a document object.
> rgb-value | Optional. The new color of links in the document.
> string | Optional. A string value specifying the color.

##### Return Value

> Returns the rgb value of the current link color.

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, title, cookie, referrer

### bgColor Property

##### Description

> Gets or sets the current color of the background in a document.

##### Syntax

> document.bgColor [=rgb-value|string]

> Part | Description
> document | An object expression that evaluates to a document object.
> rgb-value | Optional. The new color of the background in the document.
> string | Optional. A string value specifying the color.

##### Return Value

> Returns the rgb value of the current background color.

##### Remarks

> To set the background color to white, use:

>     document.bgColor="000000"

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, fgColor, anchors, links, forms, location, lastModified, title, cookie, referrer

### fgColor Property

##### Description

> Gets or sets the foreground color.

##### Syntax

> document.fgColor[=rgb-value]

> Part | Description
> document | An object expression that evaluates to a document object.
> rgb-value | Optional. The new color of the foreground in the document.

##### Remarks

> To set the foreground color to white, use:

>     document.fgColor="000000"

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, anchors, links, forms, location, lastModified, title, cookie, referrer

### anchors Property

##### Description

> Returns the array of anchors in a document.

##### Syntax

> document.anchors[integer]

> Part | Description
> document | An object expression that evaluates to a document object.

##### Return Value

> Returns an object expression that evaluates to the array of anchors.

##### Remarks

> To access the first anchor in the document, use:

>     document.anchors[0]

> To get the length of the anchors array, use:

>     document.anchors.length

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, links, forms, location, lastModified, title, cookie, referrer

### links Property

##### Description

> Returns the array of links for the current document.

##### Syntax

> document.links [integer]

> Part | Description
> document | An object expression that evaluates to a document object.

##### Return Value

> Returns an object expression that evaluates to the array of links.

##### Remarks

> To access the first link in the document, use:

>     document.links[0]

> To get the length of the links array, use:

>     document.links.length

> Note that the locations in the links collection are read-only.

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, forms, location, lastModified, title, cookie, referrer

### forms Property

##### Description

> Returns the array of forms in a document.

##### Syntax

> document.forms [integer]

> Part | Description
> document | An object expression that evaluates to a document object.

##### Return Value

> Returns an object expression that evaluates to the array of forms.

##### Remarks

> To access the first form in the document, use:

>     document.forms[0]

> To get the length of the forms array, use:

>     document.forms.length

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, location, lastModified, title, cookie, referrer

### location Property

##### Description

> Returns a read-only representation of the location object.

##### Syntax

> document.location

> Part | Description
> document | An object expression that evaluates to a document object.

##### Return Value

> Returns an object expression that evaluates to the location object of the document.

##### Remarks

> To set String1 to the document's URL, use:

>     String1 = document.location.href

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, lastModified, title, cookie, referrer

### lastModified Property

##### Description

> Returns the last modified date of the current page.

##### Syntax

> document.lastModified

> Part | Description
> document | An object expression that evaluates to a document object.

##### Return Value

> Returns a string containing the date.

##### Remarks

> To set Date1 to the document's last modified date, use:

>     Date1 = document.lastModified

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, title, cookie, referrer

### title Property

##### Description

> Returns a read-only representation of the document's title.

##### Syntax

> document.title

> Part | Description
> document | An object expression that evaluates to a document object.

##### Return Value

> Returns a string expression that evaluates to the title of the document.

##### Remarks

> To set String1 to the document's title, use:

>     String1 = document.title

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, cookie, referrer

### cookie Property

##### Description

> Gets or sets the cookie for the current document.

##### Syntax

> document.cookie [=newcookie]

> Part | Description
> document | An object expression that evaluates to a document object.
> newcookie | Optional. The new value for the cookie. Because the cookie file is just a text file, this value is a string.

##### Return Value

> Returns a string containing the current cookie.

##### Remarks

> The cookie is a string expression stored for the current page. Note that setting the cookie overwrites any current cookie information. Also note that you can use string expressions to locate particular information in the cookie string.

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, title, referrer

### referrer Property

##### Description

> Gets the URL of the referring document.

##### Syntax

> document.referrer

> Part | Description
> document | An object expression that evaluates to a document object.

##### Return Value

> Returns a string containing the URL of the referring document.

> Currently returns the URL of the referring document when there is a referrer, and NULL when there is no referrer.

##### Remarks

> The referring document is the document that contained the link the user clicked on to get to the current document. For example, if the user is on www.microsoft.com and clicks on a link to navigate to www.msn.com, the referrer property of the document for www.msn.com is www.microsoft.com. Note that by definition the referrer varies depending on how the user linked to the current document. If the user navigated to the document without clicking on a link from another page, referrer should return NULL.

##### Applies To

> Document

##### Methods

> write, writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, title, cookie

### Methods

### write Method

##### Description

> Places the given string into the current document. Unless otherwise specified, the string is appended to the current document at the current position.

##### Syntax

> document.writestring

> Part | Description
> document | An object expression that evaluates to a document object.
> string | The string to write to the current document. Note that the string is added into the HTML directly, so it must be formatted as HTML.

##### Remarks

> The following examples demonstrate the use of the write method:

>     <HTML><BODY>
>     <SCRIPT LANGUAGE="VBScript">
>     document.write ("Hello world.")
>     </SCRIPT>
>     This is a document.
>     </BODY></HTML>

> results in:

>     Hello world. This is a document.

> Whereas:

>     <HTML><BODY>
>     This is a document.
>     <SCRIPT LANGUAGE="VBScript">
>     document.write ("Hello world.")
>     </SCRIPT>
>     </BODY></HTML>

> results in:

>     This is a document. Hello world.

##### Applies To

> Document

##### Methods

> writeLn, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, title, cookie, referrer

### writeLn Method

##### Description

> Places the given string into the current document with a new-line character appended to the end.

##### Syntax

> document.writeLn string

> Part | Description
> document | An object expression that evaluates to a document object.
> string | The string to write to the current document. Note that the string is added into the HTML directly, so it must be formatted as HTML.

##### Remarks

> This method is the same as the document.write method with the addition of a newline character at the end. Note that a newline is ignored by HTML unless it is bracketed by <PRE> tags, so in many cases document.write and document.writeLn behave identically.

> The following examples demonstrate the use of the writeLn method:

>     <SCRIPT LANGUAGE="VBScript">
>     document.writeLn ("Hello world.")
>     document.write ("Hello world.")
>     </SCRIPT>

> results in:

>     Hello world.  Hello world.

> Whereas:

>     <PRE>
>     <SCRIPT LANGUAGE="VBScript">
>     document.writeLn ("Hello world.")
>     document.write ("Hello world.")
>     </SCRIPT>
>     </PRE>

> results in:

>     Hello world.
>     Hello world.

##### Applies To

> Document

##### Methods

> write, open, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, title, cookie, referrer

### open Method

##### Description

> Opens the document stream for output.

##### Syntax

> document.open

> Part | Description
> document | An object expression that evaluates to a document object.

##### Remarks

> Generally document.open is followed by a sequence of document.write or document.writeLn statements, followed by document.close. If the referenced document exists already, any information contained in the document is cleared. To write "Hello World" to the document, use:

>     document.open
>     document.writeLn "Hello World"
>     document.close

> Note that this is identical to:

>     document.writeLn "Hello World"

> with two exceptions.

> - In the first example, "Hello World" is written to the screen after document.close; in the second, it is written immediately.
> - In the first example, document.open clears the document if there is data; in the second, "Hello World" is appended to the end.

##### Applies To

> Document

##### Methods

> write, writeLn, close, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, title, cookie, referrer

### close Method

##### Description

> Updates the screen to display all of the strings written after the last open method call.

##### Syntax

> document.close

> Part | Description
> document | An object expression that evaluates to a document object.

##### Applies To

> Document

##### Methods

> write, writeLn, open, clear

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, title, cookie, referrer

### clear Method

##### Description

> Closes the document output stream and writes the data to the screen. See the open method description for more information and examples.

##### Syntax

> document.clear

> Part | Description
> document | An object expression that evaluates to a document object.

##### Applies To

> Document

##### Methods

> write, writeLn, open, close

##### Properties

> linkColor, aLinkColor, vLinkColor, bgColor, fgColor, anchors, links, forms, location, lastModified, title, cookie, referrer

© 1996 Microsoft Corporation