11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

setExpression(property, expression [, language]) Sets the expression given in<br />

string expression as the dynamic expression for the property given in string property.<br />

<strong>The</strong> optional language parameter specifies which scripting language the expression is<br />

written in, for example, "VBscript" (JScript is the default). Commonly used as a method<br />

of element nodes and Style objects. Used for setting dynamic expressions. (IE5+)<br />

swapNode(node) Exchanges the location of the object with node in the object<br />

hierarchy. (IE5+)<br />

unwatch(property) Removes the watchpoint on the property given in the string<br />

property. (N4+)<br />

watch(property, handler) ―Watches‖ the property given in string property and invokes<br />

the function handler whenever its value changes. <strong>The</strong> handler is passed the name of<br />

the property, the old value, and the value to which it is being set. Any value the function<br />

returns is interpreted as the new value for the property. (N4+)<br />

Notes<br />

With the exception of the object scriptable under traditional models (Form, Image, and<br />

so on), most elements become scriptable in Internet Explorer 4+, Mozilla/Netscape 6+,<br />

and DOM1.<br />

HTML elements are referred to both in uppercase and lowercase under the DOM, so<br />

and are both equivalent to an HTMLParagraph object.<br />

a, Anchor, Link, HTMLAnchorElement (Document Object)<br />

In traditional models, there was a separate object for an tag that specified a name attribute<br />

(called an Anchor) and one that specified an href attribute (called a Link). This nomenclature<br />

is outdated, and with the rise of the DOM there is no distinction. Modern browsers typically<br />

mesh Anchor and Link into a more appropriate object, which corresponds to any element<br />

on the page, and fill in the Anchor- or Link-related properties if they are defined. In the<br />

following list, we note explicitly those properties and methods that are available only in Anchor<br />

or Link in traditional object models.<br />

Access to these objects is achieved through standard DOM methods like<br />

document.getElementById(). However, you can also access those elements with name<br />

attribute set through the anchors[] collection of the Document, and those elements with href<br />

attribute through the links[] collection.<br />

Properties<br />

This object has the following properties in addition to those in the Generic HTML Element<br />

object listed at the beginning of this appendix:<br />

accessKey Single character string indicating the hotkey that gives the element focus.<br />

(IE4+, MOZ/N6+, DOM1)<br />

charset String indicating the character set of the linked document. (IE6+, MOZ/N6+,<br />

DOM1)<br />

coords String (comma-separated list) defining the coordinates of the object, used with<br />

the shape attribute. However, there is no default functionality. (IE6+, MOZ/N6+, DOM1)<br />

dataFld String specifying which field of a data source is bound to the element. (IE4+)<br />

dataFormatAsv String indicating how the element treats data supplied to it. (IE4+)<br />

dataSrc String containing the source of data for data binding. (IE4+)<br />

disabled Boolean indicating whether the element is disabled (grayed out). (IE4+)<br />

hash String holding the portion of the URL in the href following the hash mark (#).<br />

Defined for Link in traditional models. (IE3+, N2+, MOZ)<br />

host String holding the domain name and port portion of the URL in the href. Defined<br />

for Link in traditional models. (IE3+, N2+, MOZ)<br />

hostname String holding the domain name portion of the URL in the href. Defined for<br />

Link in traditional models. (IE3+, N2+, MOZ)<br />

href String holding the value of the href attribute, the document to load when the link is<br />

activated. Defined for Link in traditional models. (IE3+, N2+, MOZ, DOM1)<br />

hreflang String indicating the language code of the linked resource. (MOZ/N6+, IE6+,<br />

DOM1)<br />

media String indicating the media of the link. Currently unsupported. (DOM1)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!