event attribute | event property
[This documentation is preliminary and is subject to change.]
Sets or retrieves the event for which the script is written.
![]() |
Syntax
| HTML | <element event="p" ... > |
|---|---|
| JavaScript | |
Property values
Type: String
The event. The value for an onmouseover event, for example, is "onmouseover()".
Standards information
- Document Object Model (DOM) Level 2 HTML Specification, Section 1.6.5
Examples
This example uses the EVENT attribute and the event property to handle the onclick event.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/event.htm
<SCRIPT ID=oButtonScript FOR="oButton" EVENT="onclick()">
var sMessage1 = "Flip"
var sMessage2 = "Flop"
if (oButton.innerText == sMessage1) {
oButton.innerText = sMessage2;
}
else {
if (oButton.innerText == sMessage2) {
oButton.innerText = sMessage1;
}
</SCRIPT>
</HEAD>
<BODY>
:
<BUTTON ID="oButton" onmouseout="console.log(oButtonScript.event)">Flip</BUTTON>
See also
Build date: 3/8/2012
Community Content
skierpage
script "event" attribute is MS-proprietary
This property is defined in
World Wide Web Consortium (W3C) Document Object Model (DOM) Level 2
No it isn't, it is "reserved for future use". If you use <SCRIPT FOR="someObject" EVENT="someEvent"> you are deep in MS proprietary junk. In HTML4 there's no event or for attribute for the script tag, and in HTML5 the
No it isn't, it is "reserved for future use". If you use <SCRIPT FOR="someObject" EVENT="someEvent"> you are deep in MS proprietary junk. In HTML4 there's no event or for attribute for the script tag, and in HTML5 the
event
and
htmlFor
IDL
attributes of the
script element are both identified as obsolete and browsers are instructed to ignore
them.
Mr. Raymond Kenneth Petry
unclarification
A mite-confusing just what this is ...
This property returns the string-value of the event name-specification, i.e. it might better be called eventNameSpec ... it may-or-not have parentheses, which are mostly-ignored anyway e.g. EVENT=onfocus((((( works, and returns id.event="onfocus(((((".
