Created
March 12, 2012 13:00
-
-
Save Stanton/2021688 to your computer and use it in GitHub Desktop.
Cross browser JavaScript event.target
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A cross-browser method to get the correct event target | |
* @param object e The event being fired | |
* @return object targ The event target | |
*/ | |
Navigation.prototype.getEventTarget = function(e) | |
{ | |
var targ; | |
if (e.target) { // W3C | |
targ = e.target; | |
} else if (e.srcElement) { // IE6-8 | |
targ = e.srcElement; | |
} | |
if (targ.nodeType == 3) { // Safari | |
targ = targ.parentNode; | |
} | |
return targ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment