methods
- object toSource()
-
Returns a literal representing the source code of the object e.g
"function Object() { [native code] }" or "function Car(manufactuer,
model, productionyear) { this.make = manufactuer; this.model = model;
this.year = productionyear; }".
- string toString()
-
Returns a string representing the object i.e. "[object Object]".
- void unwatch(property)
-
Removes a previously set watchpoint.
// Allow all the menu items to have any value as an href.
var oMenu = document.getElementById("mnuMain");
var oMenuItems = oMenu.getElementsByTagName("li");
for (var c = 0; c < oMenuItems.length; c++) {
var oMenuItem = oMenuItems.item(c);
var oMenuLink = oMenuItem.getElementsByTagName("a").item(0);
oMenuLink.unwatch("href");
}
- object valueOf()
-
Returns the primitive value of the object e.g. "function Object() { [native code] }".
- void watch(property, handlingFunction)
-
Calls the handlingFunction when the property is changed.
// Force all the menu items to have an href of "#".
var oMenu = document.getElementById("mnuMain");
var oMenuItems = oMenu.getElementsByTagName("li");
for (var c = 0; c < oMenuItems.length; c++) {
var oMenuItem = oMenuItems.item(c);
var oMenuLink = oMenuItem.getElementsByTagName("a").item(0);
oMenuLink.watch("href", function(property, oldvalue, newvalue) {
if (newvalue != "#") {
newvalue = "#";
return newvalue;
}
});
}
properties
- accessKey
-
The key used to provide one-stroke access to the Anchor object.
- charset
-
The value provided in the charset attribute of the HTML tag, i.e. the character encoding of the resource designated by the link.
- className
-
The value provided in the class attribute of the HTML tag.
- constructor
-
The constructor method is the base method used to create an instance of the object.
- coords
-
The value provided in the coords attribute of the HTML tag. This is a comma-separated list of numbers that is
either left x-coordinate, top y-coordinate, right x-coordinate, and bottom y-coordinate (in the case of a "rect"),
center x-coordinate, center y-coordinate, and radius (in the case of a "circle"), or a series
of x-coordinate and y-coordinate pairs (in the case of a "poly").
- dir
-
The value provided in the dir attribute of the HTML tag, i.e. the directionality of the text, either LTR (left to right) or RTL (right to left).
- href
-
The value provided in the href attribute of the HTML tag, i.e. the URI of the resource.
- hreflang
-
The value provided in the hreflang attribute of the HTML tag, i.e. the base language of the resource designated by the link, coded as a language code.
- id
-
The value provided in the id attribute of the HTML tag.
- innerHTML
-
The value contained within the HTML tag for example "current page" in <a href="#">current page</a>.
- lang
-
The value provided in the lang attribute of the HTML tag, i.e. the language code representing the language in which the tag attributes are coded.
- name
-
The value provided in the name attribute of the HTML tag.
- prototype
-
Exposes the prototype for the method or property of the object.
- rel
-
The value provided in the rel attribute of the HTML tag, i.e. the link type of the resource.
- rev
-
The value provided in the rev attribute of the HTML tag, i.e. the link type of the relationship from the anchor to the document.
- shape
-
The value provided in the shape attribute of the HTML tag, i.e. "default", "rect", "circle", or "poly".
- tabIndex
-
The value provided in the tabindex attribute of the HTML tag.
- target
-
The value provided in the target attribute of the HTML tag.
- title
-
The value provided in the title attribute of the HTML tag. This text will show up as a "tooltip" in most browsers.
- type
-
The value provided in the type attribute of the HTML tag, i.e. the content type of the resource.
events
- onblur
-
- onclick
-
- ondblclick
-
- onfocus
-
- onkeydown
-
- onkeypress
-
- onkeyup
-
- onmousedown
-
- onmouseout
-
- onmouseover
-
- onmouseup
-
- onresize
-
example
// Set links with the class "popup" to open in a new window
var sWinProperties = "height=300,width=400";
var oItemList = document.getElementsByTagName("a");
for (var c = 0; c < oItemList.length; c++) {
var oItem = oItemList.item(c);
if (oItem.className == "popup") {
var oPopup = new Function("open('"+oItem.href+"',,'"+sWinProperties+"')';");
oItem.onclick = oPopup;
}
}