Anchor Examples: HTML DOM Anchor Object – Properties and Methods – Javascript Anchor Examples
Anchor Examples: HTML DOM Anchor Object – Properties and Methods – Javascript Anchor Examples
Purpose: – Illustrates the JavaScript syntax for working with the Anchor Object. An anchor allows you to create a hyperlink to another document or to a different point in the same document. The href property allows an anchor to link to another document, and the name property allows the anchor to link to another point within the current document. There are two ways to find anchors in a document: 1) use getElementById(); or 2) search through the anchors() array in the document object.
Anchor Object Examples
Standard Properties | |
className | Allows you to access the class attribute of an element |
dir | Allows you to access the direction of text |
lang | Allows you to access to the language code for an element |
title | Allows you to access an element’s advisory title |
Anchor Object Properties | |
accessKey | Allows you to access a keyboard key to access a link |
charset | Allows you to access the character-set of the linked resource |
coords | Allows you to access a comma-separated list with coordinates of a link in an image-map |
href | Allows you to access the URL of the hyperlink |
hreflang | Allows you to access the language code of the linked resource |
id | Allows you to access the id of a link |
innerHTML | Allows you to access the text of a hyperlink |
name | Allows you to access the name of a link |
rel | Allows you to access the relationship between the current document and the target URL |
rev | Allows you to access the relationship between the target URL and the current document |
shape | Allows you to access the shape of a link in an image-map |
tabIndex | Allows you to access the tab order for a link |
target | Allows you to access the where to open a link |
type | Allows you to access the MIME type of the linked resource |
Anchor Object Methods | |
blur() | Removes focus from the link |
focus() | Sets the focus on the link |