You are here: Reference > JavaScript > client-side > event handling > events > onbeforeeditfocus

onbeforeeditfocus event | beforeeditfocus event

Browser support:
Occurs before an input:file, input:password, input:text or textarea element or an element in an editable region becomes a UI-activated.
To specify an editable region, set the contentEditable property of an element to 'true' or the designMode property of the document to 'on'.
The UI-activated state differs from the activated state. For example, if you cancel the onbeforeeditfocus event on a input:text element, the element gets the focus but the caret will not be visible.

How to register:

In HTML:
<ELEMENT onbeforeeditfocus="handler">

In JavaScript:
object.onbeforeeditfocus = handler;
object.attachEvent ("onbeforeeditfocus", 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 Yes
Event object -

Actions that invoke the onbeforeeditfocus event:

For input:file, input:password, input:text and textarea elements:
  • Clicking on the element.
  • Navigating to an element with the TAB or an access key.
  • Invoking the setActive method on the element.
  • Invoking the focus method on the element.
For an element in editable mode:
  • Clicking on the element or a child of the element.
  • Navigating to the element or a child of the element with the TAB or an access key.
  • Invoking the setActive method on the element or a child of the element.
  • Invoking the focus method on the element or a child of the element.

The order of events related to the onbeforeeditfocus event:

Action Event order
Any action that invokes the onbeforeeditfocus event.
  1. onbeforeeditfocus
  2. onbeforeactivate
  3. onactivate
  4. onfocusin
  5. onfocus

Example HTML code 1:

This example illustrates the use of the onbeforeeditfocus event:
<head>
    <script type="text/javascript">
        function CancelUIActivation (event) {
                // prevent the propagation of the current event
            if (event.stopPropagation) {
                event.stopPropagation ();
            }
            else {
                event.cancelBubble = true;
            }
                // cancel the current event
            return false;
        }
    </script>
</head>
<body>
    Try to activate the second input field!
    <br /><br />
    <input accesskey="1" value="ALT + 1" />
    <input accesskey="2" value="ALT + 2" onbeforeeditfocus="return CancelUIActivation (event);" />
    <input accesskey="3" value="ALT + 3" />
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content