Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
HTML and CSS
Properties
 srcElement Property
srcElement Property

Sets or retrieves the object that fired the event.

Syntax

[ oObject = ] object.srcElement

Possible Values

oObject Object that specifies or receives the event that fired.

The property is read/write. The property has no default value.

DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are not supported in IE8 mode. For more information, see About Dynamic Properties.

Remarks

The property is read-only in Microsoft Internet Explorer 4.0, and read/write in Internet Explorer 5 and later.

Example

This example uses the srcElement property to retrieve the parent object, if needed, create the text range, move to the original object, and select the first word in the object.

<SCRIPT LANGUAGE="JScript">
function selectWord() {
    var oSource = window.event.srcElement ;
    if (!oSource.isTextEdit) 
        oSource = window.event.srcElement.parentTextEdit;
    if (oSource != null) {
        var oTextRange = oSource.createTextRange();
        oTextRange.moveToElementText(window.event.srcElement);
        oTextRange.collapse();
        oTextRange.expand("word");
        oTextRange.select();
    }
}
</SCRIPT>

Standards Information

There is no public standard that applies to this property.

Applies To

event, Event Constructor
Community Content   What is Community Content?
Add new content RSS  Annotations
event.srcElement not available in firefox      kaixin110 ... A. Grant   |   Edit   |   Show History

[N.B. MSIE onselectionchange event.srcElement is "null", too. Ray.]

<script>
function tr_onclick(evt)
{
var srcElement = evt.srcElement ? evt.srcElement : evt.target;
alert(srcElement.tagName);
}
</script>





HTML: <tr style="cursor:pointer" onclick="tr_onclick(event);"><th>Click Here</th></tr>


[jsudds.MSFT] That's correct. There are many properties that are not shared between the two implementations of the event object. You need to be careful to test your application in both browsers when using event properties, or use a event library to hide the differences from your code.

http://developer.mozilla.org/en/docs/DOM:event




Flag as ContentBug
clarification - which, fires      Mr. Raymond Kenneth Petry   |   Edit   |   Show History
N.B. The 'firing' oObject is at the bottom of the bubble, not the element checking onevent.

(There is no event.handlingElement property, and handling functions see 'this' empty.)

BUG. A null return value from srcElement.parentElement.id is not a null but an error ('hole') that crashes getElementById() and discontinues event-handling.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker