HTML and CSS Reference
In-Depth Information
attribute Function onscroll;
attribute Function onseeked;
attribute Function onseeking;
attribute Function onselect;
attribute Function onshow;
attribute Function onstalled;
attribute Function onsubmit;
attribute Function onsuspend;
attribute Function ontimeupdate;
attribute Function onvolumechange;
attribute Function onwaiting;
As you can see, this interface defines common attributes like id , title , lang , dir , and
so on. It also defines numerous event handlers like onclick , onscroll , onselect , and so
on that are associated with functions. Numerous methods are also defined.
Specific elements will inherit these scripting hooks and add to them. For example, note
the interface for the new HTML5 time element:
interface HTMLTimeElement : HTMLElement {
attribute DOMString dateTime;
attribute boolean pubDate;
readonly attribute Date valueAsDate;
This takes all the features of HTMLElement and adds to them dateTime , pubDate , and
valueAsDate properties.
As you look closely at the HTML5 script bindings, you'll notice that the difference
between an HTML5 element's attributes and the corresponding script properties is minimal.
In general, if an element has an attribute, its property will be the same, with two exceptions:
If the name of an HTML attribute is composed of multiple words, the first letter of
the all but the first word is uppercase when the name is used as a scriptable
property name. For example, the time element has a pubdate attribute; following
the previous rule, the corresponding DOM property is pubDate .
If the name of the attribute is a reserved word in JavaScript, it will be redefined
somehow. The most common attribute this rule is applied to is the class attribute,
which is widely used. The word “class” can't be used as a scriptable property name
because keyword class is reserved for future versions of JavaScript. Thus, to
change the class attribute via JavaScript, use className instead.
As long as you are aware of these two rules, the mappings between markup and script
are actually pretty straightforward.
We certainly don't expect you to become familiar with the DOM here; a sister topic,
JavaScript: The Complete Reference , of nearly the same page count covers JavaScript and its
usage with HTML and CSS. However, we do want to make it clear that the HTML5
specification combines the DOM and markup specifications together, so from here on out
the two ideas should stay more in harmony. This is generally a good thing, though it does
make the specification quite a bit larger.
Search WWH ::

Custom Search