Index u_home.gif Up Location Object



Description

An object that resides below the window in the scripting object model. The location object represents the current URL:

Setting any portion of the location object causes the browser to navigate to the newly constructed URL. The following script navigates to http://www.microsoft.com:



<script language="VBScript">

     [some preceding VBScript code]

     location.href="http://www.microsoft.com"

</script>

Properties

href, protocol, host, hostname, port, pathname, search, hash


Index u_home.gif Up Properties




Index u_home.gif Up href Property



Description

Gets or sets the compete URL for the location.

Syntax

location.href [=string]

PartDescription
location An object expression that evaluates to a location object.
string Optional. The new string value.

Return Value

Returns a string containing the complete URL for the location.

Applies To

Location

Properties

protocol, host, hostname, port, pathname, search, hash


Index u_home.gif Up protocol Property



Description

Gets or sets the protocol portion of the URL.

Syntax

location.protocol [=string]

PartDescription
location An object expression that evaluates to a location object.
string Optional. The new string value.

Return Value

Returns a string containing the protocol portion of the URL.

Remarks

For http://www.microsoft.com, this would return http:.

Applies To

Location

Properties

href, host, hostname, port, pathname, search, hash


Index u_home.gif Up host Property



Description

Gets or sets the host and port portions of the URL (hostname:port.).

Syntax

location.host [=string]

PartDescription
location An object expression that evaluates to a location object.
string Optional. The new string value.

Return Value

Returns a string containing the host and port portions of the URL.

Remarks

For http://www.microsoft.com:80, this would be www.microsoft.com:80. For file: protocols, this always returns "".

Applies To

Location

Properties

href, protocol, hostname, port, pathname, search, hash


Index u_home.gif Up hostname Property



Description

Gets or sets the host portion of the URL, either a name or an IP address.

Syntax

location.hostname [=string]

PartDescription
location An object expression that evaluates to a location object.
string Optional. The new string value.

Return Value

Returns a string containing the hostname portion of the URL.

Remarks

For http://www.microsoft.com, this would return www.microsoft.com. For file: protocols, this always returns "".

Applies To

Location

Properties

href, protocol, host, port, pathname, search, hash


Index u_home.gif Up port Property



Description

Gets or sets the port of the URL.

Syntax

location.port [=string]

PartDescription
location An object expression that evaluates to a location object.
string Optional. The new string value.

Return Value

Returns a string containing the port of the URL.

Remarks

For http://www.microsoft.com:80, this returns 80. For file: protocols, this always returns "".

Applies To

Location

Properties

href, protocol, host, hostname, pathname, search, hash


Index u_home.gif Up pathname Property



Description

Gets or sets the pathname in the URL.

Syntax

location.pathname [=string]

PartDescription
location An object expression that evaluates to a location object.
string Optional. The new string value.

Return Value

Returns a string containing the pathname portion of the URL.

Remarks

For http://www.microsoft.com/workshop/prog, this returns intdev.

Applies To

Location

Properties

href, protocol, host, hostname, port, search, hash


Index u_home.gif Up search Property



Description

Gets or sets the search portion of the URL, if specified.

Syntax

location.search [=string]

PartDescription
location An object expression that evaluates to a location object.
string Optional. The new string value.

Return Value

Returns a string containing the search portion of the URL.

Remarks

For http://www.microsoft.com/workshop/prog?user, this returns ?user. For http://www.microsoft.com/workshop/prog, this returns NULL.

Applies To

Location

Properties

href, protocol, host, hostname, port, pathname, hash


Index u_home.gif Up hash



Description

Gets or sets the hash portion of the URL, if specified.

Syntax

location.hash [=string]

ParameterDescription
location An object expression that evaluates to a location object.
string Optional. The new string value.

Return Value

Returns a string containing the hash portion of the URL.

Applies To

Location

Properties

href, protocol, host, hostname, port, pathname, search

© 1997 Microsoft Corporation. All rights reserved. Legal Notices.