HTML and CSS Reference
In-Depth Information
Events Defined by HTML5
onabort, onblur, oncanplay, oncanplaythrough, onchange, onclick,
oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave,
ondragover, ondragstart, ondrop, ondurationchange, onemptied, onended,
onerror, onfocus, onformchange, onforminput, oninput, oninvalid, onkeydown,
onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart,
onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel,
onpause, onplay, onplaying, onprogress, onratechange, onreadystatechange,
onscroll, onseeked, onseeking, onselect, onshow, onstalled, onsubmit,
onsuspend, ontimeupdate, onvolumechange, onwaiting
Events Defined by Internet Explorer
onload, onpropertychange, onreadystatechange
Element-Specific Attributes
async
Presence of this HTML5 attribute indicates that the browser might perform the fetch
or execution of the script to be asynchronously from other activity in the page. The meaning
of this attribute versus the
defer
attribute with remote scripts in particular is quite unclear.
charset
This attribute defines the character encoding of the script. The value is a space- and/
or comma-delimited list of character sets as defined in RFC 2045.
defer
Presence of this attribute indicates that the browser might defer execution of the
script enclosed by the
<script>
tag. Support for this attribute is inconsistent, though it is
now part of the HTML5 specification.
event
This Microsoft-specific attribute is used to define a particular event that the script
should react to. It must be used in conjunction with the
for
attribute. Event names are the
same as event handler attributes; for example,
onclick
,
ondblclick
, and so on.
for
The
for
attribute is used in Microsoft browsers to define the
name
or
id
of the element
to which an event defined by the
event
attribute is related. For example,
<script
event="onclick" for="button1" language="vbscript">
defines a VBScript that will
execute when a
click
event is issued for an element named
button1
.
language
This common though nonstandard attribute specifies the scripting language being
used. The Netscape implementation supports JavaScript. The Microsoft implementation
supports JScript (a JavaScript clone) as well as VBScript, which can be indicated by either
vbs
or
vbscript
. Other values that include the version of the language used, such as
JavaScript1.1
and
JavaScript1.2
, also might be possible and are useful to exclude
browsers from executing script code that is not supported. The HTML5 specification
indicates that while this attribute may be widely supported it should not be used by page
authors.
src
This attribute specifies the URL of a file containing scripting code. Typically, files
containing JavaScript code will have a
.js
extension, and a server will attach the appropriate
MIME type; if not, the
type
attribute might be used to explicitly set the content type of the
external script file. The
language
attribute also might be helpful in determining this.