
Anchor elements designate the start or destination of a hypertext link. The Anchor element requires the href or the name property to be specified.
Text and/or images can be within an anchor. To represent images that are anchors, a border in the visited or not visited color is displayed.
IHTMLAnchorElement Methods
HRESULT blur(void);
Causes a control to lose the focus and executes the code specified for the onblur event.
HRESULT focus(void);
Causes the anchor element to receive the focus and executes the code specified for the onfocus event.
HRESULT get_accessKey(
BSTR *p
);
Retrieves the accelerator key for the A object.
HRESULT get_hash(
BSTR *p
);
Retrieves the string associated with the hash property of the A object.
HRESULT get_host(
BSTR *p
);
Retrieves the host name and the optional port information of the location or URL.
HRESULT get_hostname(
BSTR *p
);
Retrieves the host-name portion of the location or URL.
HRESULT get_href(
BSTR *p
);
Retrieves the destination URL or anchor point.
This method retrieves the href property of the A object.
HRESULT get_Methods(
BSTR *p
);
Retrieves a list of methods that the user can perform on an object.
The functions that the user can perform on an object are more accurately given by the HTTP protocol when it is used, but it might, for reasons similar to the title property, be useful to include the information in advance in the link. For example, the HTML user agent might choose a different rendering as a function of the methods allowed, and thus something that is searchable might get a different icon.
HRESULT get_mimeType(
BSTR *p
);
Retrieves the MIME type for the file.
HRESULT get_name(
BSTR *p
);
Retrieves the name of the control, bookmark, or application.
This method is related to the name property of the A object.
HRESULT get_nameProp(
BSTR *p
);
Retrieves the file name from the URL that the browser uses to locate the anchor.
HRESULT get_onblur(
VARIANT *p
);
Retrieves the inline script associated with the onblur event on the A object.
HRESULT get_onfocus(
VARIANT *p
);
Retrieves the inline script associated with the onfocus event on the A object.
HRESULT get_pathname(
BSTR *p
);
Retrieves the file or object path from the URL for the current browser location.
HRESULT get_port(
BSTR *p
);
Retrieves the port number from the URL.
HRESULT get_protocol(
BSTR *p
);
Retrieves the protocol portion of the URL that the browser uses to locate the item associated with the anchor. The protocol portion, which indicates the access method, includes the initial substring of the URL up to and including the first colon.
HRESULT get_protocolLong(
BSTR *p
);
Retrieves the long name of the protocol that the browser uses to locate the item associated with the anchor (for example, "Hypertext Transfer Protocol").
HRESULT get_rel(
BSTR *p
);
Retrieves the relationship(s) described by the hypertext link from the anchor to the target.
Values and their semantics will be registered by the HTML registration authority. The default relationship, if no other is given, is void. The rel property is used only when the href property is present.
HRESULT get_rev(
BSTR *p
);
Same as the rel property, but the semantics of the link type are in the reverse direction. A link from A to B with REL="X" expresses the same relationship as a link from B to A with REV="X". An anchor can have both rel and rev properties.
HRESULT get_search(
BSTR *p
);
Retrieves the substring that follows the ? symbol in the HREF attribute of the anchor element. This is the query string or form data.
HRESULT get_tabIndex(
short *p
);
Retrieves the tab index of the element.
HRESULT get_target(
BSTR *p
);
Retrieves the target window or frame.
| _blank | Specifies to load the link into a new blank window. This window is not named. |
| _parent | Specifies to load the link into the immediate parent of the document the link is in. |
| _self | Specifies to load the link into the same window the link was clicked in. |
| _top | Specifies to load the link into the full body of the window. |
The default value for the target depends upon the URL and site. If the user does not leave the site, the default is _self, but if the user exits to a new site, the default is _top.
HRESULT get_urn(
BSTR *p
);
Retrieves a uniform resource name (URN) for a target document. The format of URNs is under discussion (1994) by various working groups of the Internet Engineering Task Force.
HRESULT put_accessKey(
BSTR v
);
Sets an accelerator key for the element. Pressing CTRL+key selects this anchor element in the user's browser.
HRESULT put_hash(
BSTR v
);
Sets the string following the # symbol in the HREF attribute of the anchor element.
This property is useful for moving to a bookmark within a document. Assigning an invalid value does not cause an error.
HRESULT put_host(
BSTR v
);
Sets the host name and the optional port information of the location or URL.
HRESULT put_hostname(
BSTR v
);
Sets the host-name portion of the location or URL.
HRESULT put_href(
BSTR v
);
Sets the destination URL or anchor point.
The HREF attribute on the anchor is a scriptable attribute. HREFs on anchors can jump to bookmarks or any element's id attribute.
HRESULT put_Methods(
BSTR v
);
Sets information about the functions that the user can perform on an object.
The functions that the user can perform on an object are more accurately given by the HTTP protocol when it is used, but it might, for reasons similar to the title property, be useful to include the information in advance in the link. For example, the HTML user agent might choose a different rendering as a function of the methods allowed, and thus something that is searchable might get a different icon.
HRESULT put_name(
BSTR v
);
Sets the name of the anchor.
This method is related to the name property of the A object.
HRESULT put_onblur(
VARIANT v
);
Sets the inline script associated with the onblur event on the A element.
HRESULT put_onfocus(
VARIANT v
);
Sets the inline script associated with the onfocus event on the A element.
HRESULT put_pathname(
BSTR v
);
Sets the file or object path of the URL.
HRESULT put_port(
BSTR v
);
Sets the port number in a URL.
HRESULT put_protocol(
BSTR v
);
Sets the protocol portion of the URL; that is, the initial substring up to and including the first colon. The protocol indicates the URL's access method.
HRESULT put_rel(
BSTR v
);
Specifies the relationship(s) described by the hypertext link from the anchor to the target.
Values and their semantics will be registered by the HTML registration authority. The default relationship, if no other is given, is void. The rel property is used only when the href property is present.
HRESULT put_rev(
BSTR v
);
Same as the rel property, but the semantics of the link type are in the reverse direction. A link from A to B with REL="X" expresses the same relationship as a link from B to A with REV="X". An anchor can have both rel and rev properties.
HRESULT put_search(
BSTR v
);
Sets the substring that follows the ? symbol in the HREF attribute of the anchor element. This is the query string or form data.
HRESULT put_tabIndex(
short v
);
Sets the tab index of the element.
HRESULT put_target(
BSTR v
);
Sets the window or frame to target.
| _blank | Specifies to load the link into a new blank window. This window is not named. |
| _parent | Specifies to load the link into the immediate parent of the document the link is in. |
| _self | Specifies to load the link into the same window the link was clicked in. |
| _top | Specifies to load the link into the full body of the window. |
If there is no frame or window that matches the specified target, a new window is opened for the link.
The default value for the target depends upon the URL and site. If the user does not leave the site, the default is _self, but if the user exits to a new site, the default is _top.
HRESULT put_urn(
BSTR v
);
Sets a uniform resource name (URN) for a target document. The format of URNs is under discussion (1994) by various working groups of the Internet Engineering Task Force.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.