ondeactivate event | deactivate event
Occurs on the active element when it loses the active state.
Only one element can be active at a time in a document.
An active element does not necessarily have focus, but an element with focus is always the active element in a document.
For example, an active element within a window that is not the foreground window has no focus.
The ondeactivate event is not cancelable.
If you want to prevent an element from losing the focus, cancel the onbeforedeactivate event.
For further details and for a cross-browser solution, please see the page for the onbeforedeactivate event.
- You can get the active element with the activeElement property.
- To set the active element in a document, use the focus and setActive methods.
- To determine whether the active element has focus, use the hasFocus method.
To detect when an element becomes active, use the onbeforeactivate, onactivate and DOMActivate events.
How to register:
In HTML:
In JavaScript:
<ELEMENT ondeactivate="handler"> |
In JavaScript:
object.ondeactivate = handler; | |||||||||||
object.addEventListener ("deactivate", handler, useCapture); |
| ||||||||||
object.attachEvent ("ondeactivate", handler); |
You can find the related objects in the Supported by objects section below.
The event object is accessible to all event handlers in all browsers.
The properties of the event object contain additional information about the current event.
To get further details about these properties and the possible event handler registration methods, please see the page for the event object.
For a complete list of events, see the page for Events in JavaScript. |
Basic information:
Bubbles | Yes |
Cancelable | No |
Event object | UIEvent |
Actions that invoke the ondeactivate event:
The order of events related to the ondeactivate event:
Action | Event order |
---|---|
Any action that invokes the ondeactivate event. |
|
Example HTML code 1:
This example illustrates the use of the ondeactivate event:
|
||||
<head> <script type="text/javascript"> function OnActivateForm (event) { event.srcElement.style.color = "red"; } function OnDeActivateForm (event) { event.srcElement.style.color = ""; } </script> </head> <body> Click on the text fields to see the result! <form onactivate="OnActivateForm (event)" ondeactivate="OnDeActivateForm (event)"> User name: <input type="text" value="my name"/><br /> E-mail: <input type="text" value="myname@mydomain.com"/> </form> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
document
HTML elements:
a, abbr, acronym, address, applet, area, b, bdo, big, blockquote, body, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldset, font, form, frame, frameset, h1, h2, h3, h4, h5, h6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:reset, input:submit, input:text, ins, isindex, kbd, label, legend, li, listing, map, marquee, menu, noframes, object, ol, p, plaintext, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, tr, tt, u, ul, var, xmp
Related pages:
External links:
User Contributed Comments