The Location object represents the current URL. The Location object can be accessed directly in VBScript. Table 3-11 describes the Location object properties. The following code shows an example of the Href property being used to navigate to a specified URL:
<SCRIPT LANGUAGE="VBScript">
Location.Href = "http://www.vb-bootcamp.com"
</SCRIPT>
Table 3-11.Location Object Properties
Property | Type | Description | Usage |
Href | String | Returns or sets the complete URL for the current location. (Example: http://www.microsoft.com) | MyVar=Location.Href |
Protocol | String | Returns or sets the protocol portion of the URL for the current location. (Example: http:, ftp:) | MyVar= Location.Protocol |
Host | String | Returns or sets the Host:Port for the current location. (For example, for http://www.microsoft.com, www.microsoft.com:80 is returned. For file: protocols, "" is returned.) | MyVar=Location.Host |
HostName | String | Returns or sets the host portion of the URL for the current location. (For example, for http://www.microsoft.com, www.microsoft.com is returned. For file: protocols, "" is returned.) | MyVar= Location.HostName |
Port | String | Returns or sets the port for communicating with the current location. (For example, for http://www.microsoft.com, 80 is returned. For file: protocols, "" is returned.) | MyVar=Location.Port |
PathName | String | Returns or sets the pathname portion of the URL for the current location. (For example, for http://www.microsoft.com/intdev, intdev is returned.) | MyVar= Location.PathName |
Search | String | Returns or sets the search portion of the URL beginning with a ?, representing a query. (For example, for http://www.microsoft.com/intdev?user, ?user is returned. For http://www.microsoft.com/intdev, NULL is returned.) | MyVar= Location.Search |
Hash | String | Returns or sets the hash portion of the URL beginning with a #. (For example, for http://www.microsoft.com/intdev#user, #user is returned.) | MyVar=Location.Hash |