event.explicitOriginalTarget

  • Revision slug: DOM/event.explicitOriginalTarget
  • Revision title: event.explicitOriginalTarget
  • Revision id: 342063
  • Created:
  • Creator: Yoshino
  • Is current revision? No
  • Comment Fixed links

Revision Content

{{ DomRef() }}

Summary

The explicit original target of the event. (Mozilla-specific)

If the event was retargeted for some reason other than an anonymous boundary crossing, this will be set to the target before the retargeting occurs. For example, mouse events are retargeted to their parent node when they happen over text nodes (see {{ Bug(185889) }}), and in that case currentTarget will show the parent and explicitOriginalTarget will show the text node.

explicitOriginalTarget differs from originalTarget in that it will never contain anonymous content.

See also Comparison of Event Targets

Example

This property can be used with <command> to get the event details of the original object calling the command.

function myCommand(ev) {
  alert(ev.explicitOriginalTarget.nodeName); // returns 'menuitem'
}

<command id="my-cmd-anAction" oncommand="myCommand(event);"/>

<menulist><menupopup>
    <menuitem label="Get my element name!" command="my-cmd-anAction"/>
</menupopup></menulist>

Specification

This is a Mozilla-specific property. Defined in {{ Source("/dom/public/idl/events/nsIDOMNSEvent.idl") }}

This event property is not defined in the W3.org DOM Level 2 Events

Revision Source

<p>{{ DomRef() }}</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>The explicit original target of the event. (Mozilla-specific)</p>
<p>If the event was <a href="/en-US/docs/DOM/event_retargeting">retargeted</a> for some reason other than an <a href="/en-US/docs/DOM/anonymous_boundary_crossing">anonymous boundary crossing</a>, this will be set to the target before the retargeting occurs. For example, mouse events are retargeted to their parent node when they happen over text nodes (see {{ Bug(185889) }}), and in that case <code><a href="/en-US/docs/DOM/event.currentTarget">currentTarget</a></code> will show the parent and <code>explicitOriginalTarget</code> will show the text node.</p>
<p><code>explicitOriginalTarget</code> differs from <code><a href="/en-US/docs/DOM/event.originalTarget">originalTarget</a></code> in that it will never contain <a href="/en-US/docs/DOM/anonymous_content">anonymous content</a>.</p>
<p>See also <a href="/en-US/docs/DOM/event/Comparison_of_Event_Targets">Comparison of Event Targets</a></p>
<h3 id="Example" name="Example">Example</h3>
<p>This property can be used with <code>&lt;command&gt;</code> to get the event details of the original object calling the command.</p>
<pre>
function myCommand(ev) {
  alert(ev.explicitOriginalTarget.nodeName); // returns 'menuitem'
}

&lt;command id="my-cmd-anAction" oncommand="myCommand(event);"/&gt;

&lt;menulist&gt;&lt;menupopup&gt;
    &lt;menuitem label="Get my element name!" command="my-cmd-anAction"/&gt;
&lt;/menupopup&gt;&lt;/menulist&gt;
</pre>
<h3 id="Specification" name="Specification">Specification</h3>
<p>This is a Mozilla-specific property. Defined in {{ Source("/dom/public/idl/events/nsIDOMNSEvent.idl") }}</p>
<p>This event property is <b>not defined</b> in the <a class="external" href="http://www.w3.org/TR/DOM-Level-2-Events/events.html">W3.org DOM Level 2 Events</a></p>
Revert to this revision