### Link Object

##### Description

> An object that resides below the document in the scripting object model. This object specifies an array of links for a given document.

> The link object is referenced as a read-only property array. A link object is constructed for every link that appears in the HTML document. A link is defined in scripting as the anchor tag <A> containing the HREF attribute, <A HREF="http://www.microsoft.com">. All properties of the link object are read-only and are the same as the location object's properties. It is only accessible through the indexed array. The following lines of script would set linktext to the third link on the page (if it exists):

>     <script language="VBScript">
>     	[some preceding VBScript code]
>     	linktext = document.links(2).href
>     	[some following VBScript code]
>     </script>

##### Events

> onMouseMove, onMouseOver, onClick

##### Properties

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

### Properties

### href Property

##### Description

> Returns the compete URL for the link.

##### Syntax

> link.href[=string]

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

##### Return Value

> Returns a string containing the complete URL for the link.

##### Applies To

> Link

##### Events

> onMouseMove, onMouseOver, onClick

##### Properties

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

### protocol Property

##### Description

> Returns the protocol portion of the URL.

##### Syntax

> link.protocol

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

##### Return Value

> Returns a string containing the protocol portion of the URL.

##### Remarks

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

##### Applies To

> Link

##### Events

> onMouseMove, onMouseOver, onClick

##### Properties

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

### host Property

##### Description

> Returns the host and port portions of the URL (hostname:port).

##### Syntax

> link.host

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

##### Return Value

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

##### Remarks

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

##### Applies To

> Link

##### Events

> onMouseMove, onMouseOver, onClick

##### Properties

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

### hostname Property

##### Description

> Returns the host portion of the URL, either a name or an IP address.

##### Syntax

> link.hostname

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

##### Return Value

> Returns a string containing the hostname portion of the URL.

##### Remarks

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

##### Applies To

> Link

##### Events

> onMouseMove, onMouseOver, onClick

##### Properties

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

### port Property

##### Description

> Returns the port of the URL.

##### Syntax

> link.port

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

##### Return Value

> Returns a string containing the port of the URL.

##### Remarks

> For http://www.microsoft.com, this returns 80 (the default for HTTP).

##### Applies To

> Link

##### Events

> onMouseMove, onMouseOver, onClick

##### Properties

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

### pathname Property

##### Description

> Returns the pathname in the URL.

##### Syntax

> link.pathname

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

##### Return Value

> Returns a string containing the pathname portion of the URL.

##### Remarks

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

##### Applies To

> Link

##### Events

> onMouseMove, onMouseOver, onClick

##### Properties

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

### search Property

##### Description

> Returns the search portion of the URL, if specified.

##### Syntax

> link.search

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

##### Return Value

> Returns a string containing the search portion of the URL.

##### Remarks

> For http://www.microsoft.com/intdev?user, this returns user.

##### Applies To

> Link

##### Events

> onMouseMove, onMouseOver, onClick

##### Properties

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

### hash Property

##### Description

> Returns the hash portion of the URL, if specified.

##### Syntax

> link.hash

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

##### Return Value

> Returns a string containing the hash portion of the URL. If no hash is specified, this property returns NULL.

##### Remarks

> The hash portion of the URL is the section after #, including the #. For http://www.microsoft.com/intdev#user, this returns #user.

##### Applies To

> Link

##### Events

> onMouseMove, onMouseOver, onClick

##### Properties

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

### target Property

##### Description

> Returns the target of the link, if specified.

##### Syntax

> link.target

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

##### Return Value

> Returns a string containing the target of the link.

##### Remarks

> This is the same as the value of the TARGET attribute of the LINK tag.

##### Applies To

> Link

##### Events

> onMouseMove, onMouseOver, onClick

##### Properties

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

### Events

Link events can be used to set status bar text or other custom actions on mouse movement. The following example is an excerpt from an HTML document that uses a text control to display rich information about the links in an image map. The code decides on the link location.

    <script language="VBScript" for="Link1" event="onMouseMove(shift, button, x, y)">
    		if (InRect(x, y,  5, 30, 120, 85)=true) then
    		DescribeLink "A full description of Microsoft's product line"
    		[some following VBScript code]
    </script>

### onMouseMove Event Handler

##### Description

> Fires an event any time the pointer moves over a link.

##### Syntax

> link.onMouseMove shift, button, x, y

> Value | Description
> link | An object expression that evaluates to a link object.
> shift | The status of the shift key.
> button | Indicates which button is pressed, if any.
> x | The horizontal position of the pointer, in pixels.
> y | The vertical position of the pointer, in pixels.

##### Remarks

> Shift and button are currently set to zero. x and y contain the actual positional data. To attach scripts or behavior to this event, use the SCRIPT tag as follows:

>     <script language=script-engine for=link-name event="onMouseMove(shift, button, x, y)">

##### Applies To

> Link

##### Events

> onMouseOver, onClick

##### Properties

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

### onMouseOver Event Handler

##### Description

> Fires an event any time the pointer moves over a link.

##### Syntax

> link.onMouseOver

> Value | Description
> link | An object expression that evaluates to a link object. Note: this does not work if the link is inside of a form.

##### Remarks

> To attach scripts or behavior to this event, use the SCRIPT tag as follows:

>     <script language=script-engine for=link-name event="onMouseOver">

> or attach a script directly in the HTML:

>     <A HREF="http://www.microsoft.com" onMouseOver="alert ('Clicked here')">To Microsoft</A>

##### Applies To

> Link

##### Events

> onMouseMove, onClick

##### Properties

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

### onClick Event Handler

##### Description

> Fires an event any time you click on a link.

##### Syntax

> link.onClick

> Value | Description
> link | An object expression that evaluates to a link object.

##### Remarks

> To attach scripts or behavior to this event, use the SCRIPT tag as follows:

>     <script language=script-engine for=link-name event="onClick">

> or attach a script directly in the HTML:

>     <A HREF="http://www.microsoft.com" onClick="alert ('Clicked here')">To Microsoft</A>

##### Applies To

> Link

##### Events

> onMouseMove, onMouseOver

##### Properties

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

© 1996 Microsoft Corporation