Discussion Forums
- Topic List
- Most Recent Posts
- Sign In for more options
Hello all, I have a problem that how i get source element from event 'e' in following example.
I given onfocus event on body tag.
function for "handleKeyboardShortcuts" is fallows -------
function handleKeyboardShortcuts(e) {
var code;
if (!e) e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
**********************************
var sourceElement = e.srcElement.tagName;
alert("source element: "+ sourceElement);
********************************
var character = String.fromCharCode(code);
//key = 'space bar'
if(code == 32 || character == "")
{
//I do something here.
}
}
I used e.srcElement.tagName; but i don't get source element.
Can any one tell me how i get it?
Thanks, vikas.
Read the Prototype docs: http://prototypejs.org/api/event/observe Prototype provides a cross-browser method for finding the target element from the event.
