DekGenius.com
Team LiB   Previous Section   Next Section
HTMLAnchorElement a hyperlink or anchor in an HTML document

Availability

DOM Level 1 HTML

Inherits from/Overrides

Node figs/U2192.gif Element figs/U2192.gif HTMLElement figs/U2192.gif HTMLAnchorElement

Properties

This interface defines the properties in the following table, which correspond to the HTML attributes of the <a> tag.

Property

Attribute

Description

String accessKey

accesskey

Keyboard shortcut

String charset

charset

Encoding of the destination document

String coords

coords

Used inside <map> elements

String href

href

URL of the hyperlink

String hreflang

hreflang

Language of the linked document

String name

name

Name of the anchor

String rel

rel

Link type

String rev

rev

Reverse link type

String shape

shape

Used inside <map> elements

long tabIndex

tabindex

Link's position in tabbing order

String target

target

Name of the frame or window in which the destination document is to be displayed

String type

type

Content type of the destination document

Methods

blur( )

Takes keyboard focus away from the link.

focus( )

Scrolls the document so the anchor or link is visible and gives keyboard focus to the link.

Description

This interface represents an <a> tag in an HTML document. href, name, and target are the key properties, representing the most commonly used attributes of the tag.

HTMLAnchorElement objects can be obtained from the links and anchors HTMLCollection properties of the HTMLDocument interface.

Example

// Get the destination URL of first the hyperlink in the document
var url = document.links[0].href;
// Scroll the document so the anchor named "_bottom_" is visible
document.anchors['_bottom_'].focus(  );

See Also

Link and Anchor objects in the client-side reference section

    Team LiB   Previous Section   Next Section