HTML DOM Anchor Object
The Anchor object represents an HTML a element
(a hyperlink)
Anchor Object
The Anchor object represents an HTML a element (a hyperlink).
For each instance of an HTML <a> tag in a document, an Anchor
object is created.
An anchor can be used in two ways:
- To create a link to another document by using the href
attribute
- To create a bookmark inside a document, by using the
name attribute
All Anchor objects in a document can be found in the Document
object's anchors array.
The Anchor object's properties and methods are described
below:
N: Netscape (including Mozilla when N6 or higher),
IE: Internet Explorer, W3C: World Wide Web Consortium
(Internet Standard)
Properties
Syntax: object.property_name
Property |
Description |
N |
IE |
W3C |
accessKey |
Sets or returns the keyboard key to
access the hyperlink |
6 |
5 |
Yes |
charset |
Sets or returns the character set of
the linked resource |
6 |
6 |
Yes |
coords |
Sets or retrieves a comma-separated
list with coordinates, defining an active region
geometry |
6 |
6 |
Yes |
href |
Sets or returns the URL of the linked
resource |
6 |
5 |
Yes |
hreflang |
Sets or returns the language code of
the linked resource |
6 |
6 |
Yes |
id |
Sets or returns the id of the hyperlink
(In IE 4 this property is read-only) |
กก |
4 |
No |
name |
Sets or returns the name of the
hyperlink |
4 |
4 |
Yes |
rel |
Sets or returns the relationship
between the current document and the target URL |
6 |
5 |
Yes |
rev |
Sets or returns the relationship
between the current document and the target URL |
6 |
5 |
Yes |
shape |
Sets or returns the active area.
Coordinates are given by coords |
6 |
6 |
Yes |
tabIndex |
Sets or returns the index that defines
the tab order for the hyperlink |
6 |
5 |
Yes |
target |
Sets or returns the window/frame where
to open the target URL |
6 |
5 |
Yes |
type |
Sets or returns the MIME type of the
linked resource |
6 |
6 |
Yes |
Methods
Syntax: object.method_name()
Method |
Description |
N |
IE |
W3C |
blur() |
Removes focus from the link |
6 |
5 |
Yes |
focus() |
Gives focus to the link |
6 |
5 |
Yes |
Events
Syntax: object.event_name="someJavaScriptCode"
Event |
Description |
N |
IE |
W3C |
onBlur |
Executes some code when the link loses
focus |
2 |
3 |
กก |
onFocus |
Executes some code when the link gets
focus |
2 |
3 |
กก |
|